Repository navigation
fix(flags): respect feature enrollment in local evaluation #1176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| pypi/posthog: patch | ||
| --- | ||
|
|
||
| Local evaluation now respects early access feature enrollment. A flag with feature enrollment uses the `$feature_enrollment/<flag key>` person property when you pass it, and otherwise falls back to the flags service. Before, it returned `False` for enrolled people who matched no release condition, while the flags service returned `True`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -492,6 +492,21 @@ def match_feature_flag_properties( | |
|
|
||
| flag_filters = flag.get("filters") or {} | ||
|
|
||
| if flag_filters.get("feature_enrollment") is True: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| enrollment_key = f"$feature_enrollment/{flag.get('key')}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if flag_filters.get("aggregation_group_type_index") is not None: | ||
| raise InconclusiveMatchError( | ||
| "Group flag has feature enrollment, which reads person properties", | ||
| reason=UnresolvedFlagReason.UNSUPPORTED_DEFINITION, | ||
| ) | ||
| if enrollment_key not in properties: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| raise InconclusiveMatchError( | ||
| f"Flag has feature enrollment and '{enrollment_key}' was not passed", | ||
| reason=UnresolvedFlagReason.MISSING_CONTEXT, | ||
| ) | ||
| enrollment = properties[enrollment_key] | ||
| return enrollment is True or enrollment == "true" | ||
|
|
||
| # Holdouts are evaluated before release conditions, so a held-out value is excluded | ||
| # from the flag's targeting entirely rather than being bucketed into a variant. | ||
| holdout_variant = _get_holdout_variant(flag, bucketing_value) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Every early access feature's flag hasfeature_enrollment: True, so aget_all_flagscall without$feature_enrollment/<key>now makes a/flagsrequest, andonly_evaluate_locally=Truedrops those flags from the result. Should this be a minor bump with a "Behavior changes" note, like 7.79.0, that says to pass the property or useflag_keys?