Skip to content

fix: keep sticky buckets past a failing rule condition and honor null force rules - #166

Merged
vazarkevych merged 3 commits into
mainfrom
fix/161-sticky-bucket-and-null-force
Dec 1, 2026
Merged

vazarkevych merged 3 commits into
mainfrom
fix/161-sticky-bucket-and-null-force

Conversation

@madhuchavva

@madhuchavva madhuchavva commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #161. Supersedes #162 — its commit is carried over unchanged, authorship kept.

Summary

  • A sticky-bucketed user stays in their variation when an experiment rule's condition stops matching.
  • A feature rule with "force": null is a force rule that serves null, as in the JS SDK ("force" in rule).
  • Both are pinned in tests/cases.json with 12 new cases.

Root cause

  • _eval_feature checked rule.condition for every rule before _run_experiment, so the sticky bucket lookup never ran. The JS SDK moved that check into the force branch when sticky bucketing shipped (Sticky bucketing (SDK) growthbook#1818); the Python port in v1.1.0 did not.
  • rule.force is not None cannot tell a null force from a missing one.
  • No stickyBucket case had a user failing the rule condition, and no feature case had force: null, so the conformance suite passed.

Behavioral change

  • A sticky-bucketed user who fails the rule condition stays in the experiment instead of falling through to later rules.
  • forced_variations and the ?exp=N querystring override apply even when the rule condition fails.
  • Subscriptions fire with inExperiment=False for experiment rules skipped by their condition.
  • "force": null in a payload, or FeatureRule(force=None), serves None with source force. Before, the rule was skipped, or ran as an experiment when it also had variations.

Follow-ups

  • The new cases are Python-local extras (the corpus freshness check reports them, never fails on them). They should go upstream to the JS SDK's cases.json.
  • Step 3 of evalFeature in the build-your-own spec still checks rule.condition for every rule.

Test plan

  • pytest tests/ -q --ignore=tests/test_live.py — 1872 passed locally; the 2 failures and 2 errors are identical on main in the same environment
  • stickyBucket (+6) and feature (+6) cases: expected values generated with @growthbook/growthbook 2.2.0; the full fixture replays through it 19/19 and 70/70
  • New cases against unfixed main: 7 failures for the sticky bucket fix, 3 for force: null
  • python3 tests/scripts/check_corpus_freshness.py — OK, no missing or drifted cases
  • pyright — 0 errors

vazarkevych and others added 3 commits November 23, 2026 13:30
_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
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Reviews (1) · Last reviewed commit: "fix: treat a feature rule with a null fo..." · Reviewed by Greptile

@andywhite37 andywhite37 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches the JS SDK's evalFeature order. The new tests fail when either fix is reverted, and CI is green. Upstreaming the cases and the spec fix stay as follow-ups.

@vazarkevych
vazarkevych merged commit 9ab2b3d into main Dec 1, 2026
8 checks passed
@vazarkevych
vazarkevych deleted the fix/161-sticky-bucket-and-null-force branch December 1, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky-bucketed users fall back to the default value when an experiment rule's condition is narrowed (JS SDK keeps them)

3 participants