Repository navigation
test: cover $inGroup/$notInGroup for an absent attribute - #287
Merged
Merged
Conversation
evalSavedGroup returned false for both $inGroup and $notInGroup whenever the targeted attribute was absent, because of an early `actual == null` guard. Since the two operators are logical negations, collapsing both to false is inconsistent: per the JS SDK (packages/sdk-js/src/mongrule.ts), $notInGroup on an absent attribute must be true. Drop the actual-null guard and let isIn (which already treats null as a non-member) drive both operators, so they match the JS truth table across member / non-member / absent / unknown-group inputs. Also resolve a non-array saved-group value to an empty group instead of throwing from getAsJsonArray(). The conformance corpus has no absent-attribute $notInGroup case, so this gap is covered by dedicated unit tests.
[Medium impact] The PR appears safe to merge. Reviews (1) · Last reviewed commit: "fix: correct $notInGroup for an absent a..." · Reviewed by Greptile |
…-attribute # Conflicts: # lib/src/main/java/growthbook/sdk/java/evaluators/ConditionEvaluator.java # lib/src/test/java/growthbook/sdk/java/ConditionEvaluatorTest.java
andywhite37
approved these changes
Nov 4, 2026
andywhite37
left a comment
Contributor
There was a problem hiding this comment.
Thanks, these tests are useful. The fix already reached main with spec 0.12.0, so I've retitled this to test: to keep it out of the release notes.
vazarkevych
pushed a commit
that referenced
this pull request
Nov 6, 2026
Brings in spec 0.12.0 alignment (#284), the 0.12.0 release and the $inGroup/$notInGroup absent-attribute tests (#287). Conflicts: - GrowthBookClient: keep both new imports (FeatureRule from this branch, ReducePayloadOptions from main). - GrowthBookClientTest: keep main's two sticky-preload regression tests. They fail against the scoped async read path here; the next commit fixes the code they exposed and scopes them to identifier attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: correct $notInGroup for an absent attribute
$inGroupand$notInGroupboth returnedfalsefor a missing attribute — a logical contradiction;$notInGroupnow returnstrue, matching the JS SDKlib only · evaluation behavior change · no new dependencies · JS parity
Branch:
fix/notingroup-absent-attributeCommit:
938d252(fix)Summary
ConditionEvaluator.evalSavedGroupreturnedfalsefor both$inGroupand$notInGroupwhenever the targeted attribute was absent, because of an early
actual == nullguard. Since the twooperators are logical negations of each other, collapsing both to
falseis internally inconsistent —at least one must be wrong.
Per the reference JS SDK (
packages/sdk-js/src/mongrule.ts),$notInGroupon an absent attributemust be
true.The gap
$inGrouptruetrue$inGroupfalsefalse$inGroupfalsefalse$notInGroupfalsefalse$notInGrouptruetrue$notInGrouptruefalse← wrong$notInGrouptruetrueThe conformance corpus (spec 0.11.3) covers member / non-member / unknown-group / type-mismatch, but
has no absent-attribute
$notInGroupcase, so the gap passed CI unnoticed.The fix
actual == nullguard and letisIn— which already treats a null attribute as anon-member — drive both operators, so they agree with the JS truth table across
member / non-member / absent / unknown-group inputs.
isJsonArray()check) instead of throwingfrom
getAsJsonArray().$inGroupbehavior is unchanged for every input; only$notInGroupon an absent attribute flipsfalse → true. Lives inConditionEvaluator, shared by both theGrowthBookandGrowthBookCliententry points.
Tests
Two new
ConditionEvaluatorTestcases (the corpus can't cover this path):test_savedGroupOperatorsMatchReferenceTruthTable— the full$inGroup/$notInGrouptruthtable, including the absent-attribute and unknown-group rows.
test_savedGroupOperatorsTolerateNonArrayGroupValue— a non-array saved-group value resolves toan empty group instead of throwing.
Both pass on JDK 17.