Repository navigation
Add a flag selection option to the OpenFeature provider - #13291
Conversation
Move the ffe-system-test-data submodule from 8c4d241 to e8777633, which adds the shared flag-selection/selection-vectors.json. Environment: Datadog workspace
Provider.Options.flagSelection(FlagSelection) sends the selected tags and key patterns on the agentless configuration request, so the provider loads only the flags the backend returns. The selection is canonicalized and validated as in the other Datadog SDKs and checked against the shared flag-selection vectors. A selection that cannot be sent is dropped with an error log and the full configuration is loaded; a selection the server ignores is logged once per reason after the configuration is applied. The first provider initialized in a class loader claims the selection until the last provider shuts down. Solves FFL-3572. Environment: Datadog workspace
A provider joining a Remote Config runtime with a selection now logs the Remote Config warning too, once per class loader, instead of only the provider that started the runtime. Also write the White_Space set and the non-ASCII test values as escapes, and cover the legacy Remote Config setting and repeated polls over the URL limit. Environment: Datadog workspace
Copy the arrays a selection list returns, so a list breaking the toArray contract is malformed input instead of a NullPointerException. Cover the Remote Config warning for an invalid selection, a joining provider with a different dropped selection, the once-per-reason counts across reasons and kinds, the deprecated alias return type and an encoded endpoint path. Document the URL-length drop, the once per class loader second-selection warning and the query parameters a custom endpoint must forward, and use a non-team tag in examples. Environment: Datadog workspace
Remote Configuration delivers the full configuration and uses no flag selection, so a later provider with a different selection only gets the Remote Config warning: "Using the first selection" would be inaccurate. Environment: Datadog workspace
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f4d62b6bf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
More details
Validation is limited to source review: backend interoperability remains unverified, and the shared canonicalization vectors could not be inspected because the test-data submodule was unavailable.
🤖 Bits Code Review · Commit 0f4d62b
|
A broader note about
Dependencies. I think a standalone SDK like this should have no dependencies of its own, or bundle (shade) the ones it needs:
Again, none of this blocks this PR. It should be a separate piece of work. |
Encode each value to UTF-8 once and reuse it for the size check and the request URL, replace the toArray() copy with a null check, hash without a varargs array, and stop asserting exact vector counts so new cases in the shared test data do not break the test. Environment: Datadog workspace
|
@dougqh Thanks for the context on the — Claude Code working with Mark |
leoromanovsky
left a comment
There was a problem hiding this comment.
One additional finding from the HTTP reproduction.
Read every DD-Flag-Selection-Ignored field and join repeated fields with ", ", the way the other SDKs read them, so duplicates and an empty first field report unknown instead of taking only the first value. The test server can now send a header name more than once. Environment: Datadog workspace
…flags differ A provider joining the shared runtime with a selection that differs from the claimed one now logs and counts its own drop (malformed or over a limit), and gets the "differs" warning only when it would load different flags than the runtime does. A dropped selection and no selection both load every flag, so they no longer trigger a false "differs". Environment: Datadog workspace
Take master's ffe-system-test-data pointer (6df74e6), which already contains the PR's pointer (e877763).
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
|
/merge |
|
View all feedbacks in Devflow UI.
PR already in the queue with status in_progress |
What Does This Do
Lets an application load only part of its flag configuration:
With a selection, the agentless configuration request carries repeated
selected_flag_tagsandselected_flag_key_patternsquery parameters, and the provider serves only the flags the backend returns. A flag outside the selection evaluates to the default value withFLAG_NOT_FOUND. Without a selection, the request, the ETag handling and the loaded configuration are unchanged.Motivation
A service that uses a few flags of a large Datadog project still downloads, parses and holds the whole flag configuration. A flag selection lets it fetch and keep only the flags it needs, which shrinks the payload and the memory it holds. The browser, iOS and Android SDKs already support it; this gives the Java server SDK the same option, with the same canonical form and diagnostics.
Additional Notes
White_Space, deduplicated and sorted by UTF-8 bytes, then percent-encoded per RFC 3986. The JDK helpers don't fit:String.trim()andString.strip()each disagree withWhite_Space,String.compareTosorts by UTF-16 code units, andURLEncoderis form encoding (+for a space,*kept).FlagSelectionVectorsTestruns the 38 SDK cases of the sharedflag-selection/selection-vectors.jsonand skips the 6rawQuerycases, which test the server's percent-decoding. Theffe-system-test-datasubmodule moves from8c4d241toe8777633, a single commit that adds these vectors and their validator.Stringelement (possible through a raw list) or an unpaired surrogate ismalformed_selection. More than 31 values in a list, a value over 200 UTF-8 bytes, or a request URL over 8192 bytes also drops the selection. A dropped selection is not sent: the provider logs one error per provider initialization, naming the reason and the limit but never the values, and loads all the flags. Formalformed_selectionthe limit text is the browser SDK's, with "lists" for the Java type:flagSelection must be an object with optional tags and keyPatterns string lists.DD-Flag-Selection-Ignoredresponse header is read only on a 200 to a request that carried a selection. Its value is kept only when it is exactly one of the five known reasons, and isunknownotherwise. It is logged once per reason, after the configuration is applied.selected_flag_*query parameters and theDD-Flag-Selection-Ignoredheader.flag_selection.droppedandflag_selection.ignored, tagged withreason, go through the existing health metrics once per reason, so they needdd-java-agent. Without the agent, the error logs are the only signal. The telemetry intake drops these two counts until they are registered there, which is separate work.FlagSelectionandOptions.flagSelectionare new public API, also on the deprecateddatadog.trace.api.openfeature.Provider.Optionsalias. The option is set in code only: there is no environment variable or system property.8c4d241tod8911fd#13183 both move theffe-system-test-datasubmodule. Whichever merges second should taked8911fd, Bump dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data from8c4d241tod8911fd#13183's commit, whoseflag-selection/is identical toe8777633.ProviderTest.testNullConfigurationAfterReadyTransitionsToErrorAndRecoversfailed once in a full local run of the module (a Mockito invocation count on a configuration-change handler) and passed in isolated runs on this branch and on master. The test and its no-selection path are unchanged here, so it looks like an existing timing flake.tests/parametric/test_ffe/test_flag_selection.pyfrom DataDog/system-tests at43145a9454085892244bd237269df9bc2c66169c, against this branch ate3d668be4ca4b45f440e7187693a860bf34ccb30, loaded throughbinaries/(thedd-java-agent,dd-trace-apianddd-openfeaturejars built from this commit); the run reported the library asjava@1.69.0-SNAPSHOT+e3d668be4c. Command:TEST_LIBRARY=java ./run.sh PARAMETRIC -F tests/parametric/test_ffe/test_flag_selection.py tests/parametric/test_ffe/test_flag_selection.py. Result: 12/12 pass (the 11 case files of the flag-selection evaluation suite (tags, key-patterns, tags-or-key-patterns, canonical-form, interior-whitespace-tag, selection-matches-no-flag, sdk-sends-selection-at-limits, server-ignores-selection, empty-selection, sdk-drops-too-many-values, sdk-drops-long-url) plus the ETag revalidation test). Regression check, all oftests/parametric/test_ffe/without-F: 98 passed, 0 failed. Parametric-app wiring used locally:FeatureFlagEvaluatorControllertakes an optional/startbody, stores the selection before the lazy client is first used, and callsOptions.flagSelection(FlagSelection)by reflection so the app still compiles against released versions. The suite's manifest entry for this library is stillmissing_featureand the parametric-app wiring lands in a separate system-tests PR, so PR CI cannot show this run yet.31c92052b4, an earlier head of this branch: a staging end-to-end harness builds the provider with each selection against the staging backend. 11/11 cases pass direct and 13/13 through a recording proxy that checks the exact query sent; a negative control without the option loads every flag for all 8 selection cases.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: FFL-3572