Repository navigation
fix(flags): canonicalize numeric group keys for local bucketing - #1071
turnipdabeets merged 3 commits into
Conversation
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
Commit signatures resolvedGitHub now verifies every commit signature in this PR. No further action is needed. |
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
b3c2c99 to
07588b4
Compare
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
# Conflicts: # posthog/feature_flags.py
NumPy and other registered Integral types previously bucketed as their decimal string; restrict-to-int would have turned them inconclusive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK performance: posthog-pythonBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
turnipdabeets
left a comment
There was a problem hiding this comment.
Thanks @Kayvan-Zahiri !
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.