-
Notifications
You must be signed in to change notification settings - Fork 52
feat(server): expose flags that local evaluation could not resolve #827
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
Draft
gustavohstrassburger
wants to merge
1
commit into
main
Choose a base branch
from
gustavo/expose-unresolved-local-flags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "posthog-server": minor | ||
| --- | ||
|
|
||
| Add `unresolvedFlags` to the `evaluateFlags()` snapshot. It lists the flags that have a local definition but no value, because local evaluation could not resolve them and no `/flags` fallback filled them, for example with `onlyEvaluateLocally`. Each entry has a `PostHogUnresolvedFlagReason`: `EXPERIENCE_CONTINUITY`, `UNSUPPORTED_DEFINITION`, `MISSING_CONTEXT` or `UNRESOLVED_DEPENDENCY`. Reading such a flag now reports `$feature_flag_error: local_evaluation_inconclusive` instead of `flag_missing`, so insights that filter on `flag_missing` count fewer events. The SDK also logs one warning per flag version when loaded definitions include an active flag with experience continuity. |
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
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
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
30 changes: 30 additions & 0 deletions
30
posthog-server/src/main/java/com/posthog/server/PostHogUnresolvedFlagReason.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.posthog.server | ||
|
|
||
| /** | ||
| * Why local evaluation could not resolve a flag that has a loaded definition. Reported by | ||
| * [PostHogFeatureFlagEvaluations.unresolvedFlags]. Each reason says what the caller can do about it. | ||
| * | ||
| * @property value The stable string for this reason, as defined by the SDK spec. | ||
| */ | ||
| public enum class PostHogUnresolvedFlagReason(public val value: String) { | ||
| /** The flag has experience continuity enabled. Local evaluation never resolves it; change the flag. */ | ||
| EXPERIENCE_CONTINUITY("experience_continuity"), | ||
|
|
||
| /** | ||
| * The flag uses something the local evaluator does not support, such as a static cohort, an | ||
| * unrecognized operator or a malformed value. Change the flag or upgrade the SDK. | ||
| */ | ||
| UNSUPPORTED_DEFINITION("unsupported_definition"), | ||
|
|
||
| /** | ||
| * The call did not supply a property, group key or group property the flag's conditions need, | ||
| * or supplied it in a form the evaluator cannot use. Pass it. | ||
| */ | ||
| MISSING_CONTEXT("missing_context"), | ||
|
|
||
| /** | ||
| * A flag this flag depends on could not be resolved. Check the dependency's own reason; it appears | ||
| * in [PostHogFeatureFlagEvaluations.unresolvedFlags] only when the dependency is in the requested scope. | ||
| */ | ||
| UNRESOLVED_DEPENDENCY("unresolved_dependency"), | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
A group flag evaluated without its group key resolves to
false; it does not appear inunresolvedFlagswithMISSING_CONTEXT. This documentation tells callers to expect a signal they will not receive. Remove “group key” from the description, or change evaluation to report that case as inconclusive.Knowledge Base Used: Server feature-flag evaluation
Prompt To Fix With AI