Repository navigation
Conversation
Environment flags are now evaluated with segments, so identity-less `$.flags` and `$.environment` conditions apply to them. Lazily resolved identity flags overridden by a segment reading `$.flags` are evaluated against the full context, so their dependencies resolve. Closes #245
Replace the regex with the JSONPath parser the engine uses, mirroring how the engine reads condition properties. A property is ruled out only when its first segment selects top-level keys by name, none of them `flags`, so ambiguous selectors fall back to full-context evaluation.
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.
Closes #245.
Changes
get_environment_flags()in local evaluation / offline mode no longer stripssegmentsfrom the evaluation context (fix:get_environment_flagsincludes segments in evaluation context #179 added the stripping), so identity-less$.flags.<feature>.<enabled|value|variant>and$.environment.*conditions now apply to environment flags.$.flagsdependencies.Flags.get_flag()evaluates against a trimmed context: just the queried feature and the segments that override it. That trimmed context leaves out the flags a$.flagscondition reads, so those conditions never matched. Features overridden by a segment with a$.flagscondition are now found once per environment refresh (build_flag_dependent_feature_names). For those features,get_flag()evaluates the full context and memoises every resulting flag. All other features keep the trimmed fast path.jsonpath-rfc9535, the parser the engine uses, and follows the engine's rules: only$.-prefixed properties that compile are JSONPath. A property is treated as reading$.flagsunless its first segment selects top-level keys by name and none of them isflags. Wildcards, filters and$..count as possibly reading it, so a wrong guess only costs speed, never correctness.jsonpath-rfc9535is now a direct dependency, with the same>=0.1.5,<1range as the engine.^11.1.1(deps: update dependency flagsmith-flag-engine to v11.1.0 #252, deps: bump flagsmith-engine to 11.1.1 #259), which includes$.flagssupport (feat: Evaluate flags that depend on other flags flagsmith-engine#343).Behaviour change
Environment flags can now pick up segment overrides from segments whose rules match without an identity, e.g.
$.environment.nameconditions orIS_NOT_SETon a trait. This is what #245 asks for, and it matches theget_evaluation_resultsemantics discussed in Flagsmith/flagsmith#6051. Note that remote/api/v1/flagsmay still return plain environment defaults.Tests
test_get_environment_flags_omits_segments_from_evaluation_contextbecomes..._includes_segments_....$.flags/$.environmentoverrides on environment flags and identity flags. These include a dependency that is itself overridden for an identity.$.flagsproperty detection (dot/bracket/descendant forms, nested rules) and for full-context resolution and memoisation in lazyFlags.