Skip to content

fix: use force rule fallbackAttribute only with sticky bucketing - #163

Merged
madhuchavva merged 1 commit into
mainfrom
fix/force-rule-fallback-attribute
Dec 3, 2026
Merged

madhuchavva merged 1 commit into
mainfrom
fix/force-rule-fallback-attribute

Conversation

@vazarkevych

Copy link
Copy Markdown
Collaborator

What changed and why

Force-rule rollouts passed rule.fallbackAttribute to _isIncludedInRollout unconditionally. So a user without the hash attribute could be included through the fallback even with sticky bucketing off. The JS SDK passes the fallback for rollouts only when sticky bucketing is enabled and the rule does not set disableStickyBucketing. That is the same rule #153 already applied to experiments.

_experiment_fallback_attribute now accepts a FeatureRule as well as an Experiment, and force rules use it.

Checked against @growthbook/growthbook 2.0.0. The test rule is {"force": "on", "coverage": 1, "hashAttribute": "id", "fallbackAttribute": "deviceId"}, with attributes {"deviceId": "dev-1"}:

Case JS 2.0.0 Python before Python after
no sticky bucket service off / defaultValue on / force off / defaultValue
sticky bucket service on / force on / force on / force
sticky + disableStickyBucketing off / defaultValue on / force off / defaultValue

Behaviour change

If you rely on fallbackAttribute for percentage rollouts without a sticky bucket service, users who lack the hash attribute are no longer included. This is not marked breaking because it is a parity fix, but it should be called out in the changelog.

test_unhashable_ids_use_the_fallback_attribute asserted the old behaviour ("Rollouts always use the rule's fallback attribute"). It now asserts the JS behaviour, with and without a sticky bucket service. Please confirm this was not an intentional divergence in #153.

How to test

  • pytest tests/test_force_rule_fallback_attribute.py: 4 tests, covering the three cases above plus a rule where the hash attribute is present.
  • pytest tests/test_growthbook.py -k unhashable_ids
  • Full suite: all pass except two tests/test_typing.py mypy cases that also fail on main.

Limitations / follow-ups

Force-rule rollouts passed rule.fallbackAttribute to _isIncludedInRollout
unconditionally, so a user without the hash attribute could be included
through the fallback even when sticky bucketing was off. The JS SDK
(core.ts, verified against @growthbook/growthbook 2.0.0) uses the fallback
for rollouts only when sticky bucketing is enabled and the rule does not
set disableStickyBucketing, the same rule 4.0.0 already applies to
experiments. Reuse _experiment_fallback_attribute for force rules.

Users relying on fallbackAttribute for rollouts without a sticky bucket
service are no longer included when the hash attribute is missing.
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Reviews (2) · Last reviewed commit: "fix: use force rule fallbackAttribute on..." · Reviewed by Greptile

@vazarkevych

Copy link
Copy Markdown
Collaborator Author

@greptile review

@madhuchavva

Copy link
Copy Markdown
Contributor

Confirming this is a regression from #153, not an intentional divergence.

Merging for 4.1.1.

Nit: row 3 of the table (sticky + disableStickyBucketing) already returns off on main, since FeatureRule clears the fallback attribute in that case.

Follow-up: nothing in cases.json covers a force rule with fallbackAttribute, which is why neither behaviour was flagged. These tests should move there.

@madhuchavva
madhuchavva merged commit f19a1d8 into main Dec 3, 2026
8 checks passed
@madhuchavva
madhuchavva deleted the fix/force-rule-fallback-attribute branch December 3, 2026 03:11
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.

2 participants