Repository navigation
fix: keep sticky bucket when experiment rule condition no longer matches - #162
Closed
vazarkevych wants to merge 1 commit into
Closed
vazarkevych wants to merge 1 commit into
vazarkevych wants to merge 1 commit into
Conversation
_eval_feature checked rule.condition for every rule before running the experiment, so a sticky-bucketed user who stopped matching a narrowed condition fell back to the default value. Check rule.condition up front only for force rules; experiment rules rely on _run_experiment, which skips the condition when a sticky bucket is found. Matches the JS SDK (core.ts) and growthbook-php#91. A forced variation now also applies when the user fails the experiment rule's condition, as in JS. Fixes #161
[Medium impact] The PR appears safe to merge; no actionable defects were found. Reviews (2) · Last reviewed commit: "fix: keep sticky bucket when experiment ..." · Reviewed by Greptile |
Collaborator
Author
|
@greptile review |
5 tasks
Contributor
|
Thanks for addressing this. Changes are ported into PR #166 — your commit is carried over unchanged, along with conformance cases for it in |
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.
Fixes #161
What changed and why
With sticky bucketing on, a user who was bucketed into an experiment and then stopped matching the rule's
condition(for example, the condition was narrowed mid-test) fell back to the feature's default value. The JS SDK keeps them in their stored variation._eval_featurecheckedrule.conditionfor every rule before running the experiment, so the sticky bucket lookup in_run_experimentnever ran. Nowrule.conditionis checked up front only for force rules, inside therule.force is not Noneblock. Experiment rules go straight to_run_experiment, which already checks the condition only when no sticky bucket is found.This matches
evalFeaturein the JS SDK (core.ts, the"force" in ruleblock) and the same fix in growthbook/growthbook-php#91. The order of checks in the rule loop now matches JS: prerequisites → filters → force (condition, rollout) → experiment.Side effects, both matching JS:
forced_variationsor?exp=1) now applies even when the user fails the experiment rule's condition.on_experiment_viewed-style subscriptions (callback_subscription) now also see experiment rules whose condition fails, with aninExperiment=Falseresult.How to test
pytest tests/test_sticky_bucket_rule_condition.py: 7 tests ported from growthbook-php#91. The first three fail without the fix:new/experimenton the second call, the same as@growthbook/growthbook2.0.0.tests/test_typing.pymypy cases that also fail onmain.Limitations / follow-ups
rule.conditionfor every rule. This PR follows the JS SDK, which is the reference implementation here.