Repository navigation
fix: empty variations or short meta in a rule crashed evaluation with IndexError - #137
Merged
Merged
Conversation
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.
Summary
_getExperimentResultraised an uncaughtIndexErroron two malformed payload shapes; both now degrade the way the evaluation contract expects instead of crashing feature evaluation.Root cause
The out-of-range clamp sets
variationId = 0and then indexes unconditionally:variations: [](orcontextualVariations: []on a bandit rule) →experiment.variations[0]→IndexErrorat core.py:1443. Pre-existing, not a bandit regression — reproduced on v3.0.0 with a plainvariations: []rule; the CB shape is just a second door into it.metashorter thanvariations(e.g. 2 variations, 1 meta entry, user hashes into variation 1) →experiment.meta[1]→IndexErrorat core.py:1422.Behavioral change
None(the JS SDK readsundefinedthere), the result staysinExperiment=False, and the rule falls through to the feature'sdefaultValue— identical user-visible behavior to JS.keyfalls back to the variation id). The JS SDK crashes here too (.keyoffundefined), so this half is a deliberate Python-stricter divergence on invalid payloads only.Follow-ups
cases.jsoncorpus (JS repo) so all SDKs pin the fall-through behavior.TypeError(same latent crash ingetExperimentResult).Test plan
pytest tests/test_growthbook.py -k "empty_variations or empty_contextual or meta_shorter"pytest tests/ -q— 972 passed (2 known local-envtest_typing[*-mypy]deselects)--select=E9,F63,F7,F82clean