Commit 68c7b39
committed
Fix multi-condition flags with static cohorts returning wrong variants
When a feature flag has multiple conditions and one contains a static
cohort, the SDK now correctly falls back to the API instead of
evaluating subsequent conditions locally and returning incorrect variants.
Introduce RequiresServerEvaluation exception to distinguish between:
- Missing server-side data (static cohorts) → immediate API fallback
- Evaluation errors (bad regex, missing properties) → try next condition
Changes:
- Add RequiresServerEvaluation exception class
- Update match_cohort() to throw RequiresServerEvaluation for static cohorts
- Update match_property_group() to propagate RequiresServerEvaluation
- Update match_feature_flag_properties() to handle both exception types
- Update client.py to catch both exceptions for API fallback
- Export RequiresServerEvaluation in __init__.py
- Add test for multi-condition static cohort scenario
All 84 feature flag tests pass.1 parent e06830e commit 68c7b39
File tree
4 files changed
+101
-4
lines changed- posthog
- test
4 files changed
+101
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
1583 | 1587 | | |
1584 | 1588 | | |
1585 | 1589 | | |
1586 | | - | |
| 1590 | + | |
1587 | 1591 | | |
1588 | 1592 | | |
1589 | 1593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
| |||
239 | 251 | | |
240 | 252 | | |
241 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
242 | 257 | | |
| 258 | + | |
| 259 | + | |
243 | 260 | | |
244 | 261 | | |
245 | 262 | | |
| |||
449 | 466 | | |
450 | 467 | | |
451 | 468 | | |
452 | | - | |
453 | | - | |
| 469 | + | |
| 470 | + | |
454 | 471 | | |
455 | 472 | | |
456 | 473 | | |
| |||
503 | 520 | | |
504 | 521 | | |
505 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
506 | 526 | | |
507 | 527 | | |
508 | 528 | | |
| |||
552 | 572 | | |
553 | 573 | | |
554 | 574 | | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
555 | 578 | | |
556 | 579 | | |
557 | 580 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3013 | 3013 | | |
3014 | 3014 | | |
3015 | 3015 | | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
| 3061 | + | |
| 3062 | + | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
| 3072 | + | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
3016 | 3085 | | |
3017 | 3086 | | |
3018 | 3087 | | |
| |||
0 commit comments