Repository navigation
fix(flags): canonicalize numeric group keys for local bucketing - #1071
Draft
Kayvan-Zahiri wants to merge 1 commit into
Draft
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Motivation and context
Numeric group identifiers currently reach the local rollout hash through Python string interpolation. For a group flag called
group-betaat 50% rollout, group key0.00001hashes as1e-05, returning false, while its canonical string key"0.00001"returns true. Invalid group keys such as booleans or containers can also return a definitive local result instead of leaving remote evaluation eligible.Normalize group keys before bucketing in both legacy flag-level aggregation and mixed condition-level aggregation. Strings stay unquoted, finite numbers use the existing backend-compatible JSON rendering, and unsupported values raise the evaluator's existing inconclusive signal. No public method, option, or type is added.
This follows the published group-key bucketing requirement.
Verification
The new tests use the public
Client.get_feature_flag()andClient.evaluate_flags()APIs with locally loaded definitions. They cover legacy/mixed aggregation, finite numeric/string controls, unsupported boolean/null/container/non-finite values, and remote fallback. Before the fix there are 16 failing subtests; after it all pass.Focused flag suites: 293 passed, 37 subtests passed. Full SDK suite: 4,620 passed, 16 skipped, 78 subtests passed (134 warnings). Repository-wide Ruff formatting/lint, mypy across 300 source files, and the public API snapshot check pass. The local SDK was exercised against its own evaluator and mocked remote responses; no hosted production flag configuration was changed.
A patch changeset is included. No public API snapshot changes are expected.
Agent context
Autonomy: Fully autonomous
Codex independently selected and reproduced this defect while exercising the Python SDK, implemented the scoped fix, and ran regression and quality checks. A human authorized contribution work but has not reviewed this implementation. The PR is a draft and requires human review; it will not be auto-approved or merged.