feat(openfeature): add flag_selection provider option #6652
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6652"
general
weight: 0.35
joepeeples
Why
Services that use only some of their feature flags still download and hold the full flag configuration. The browser, iOS, and Android SDKs already let an application request a subset.
What
Datadog::OpenFeature::Provider.new(flag_selection: {tags:, key_patterns:})sends a canonical selection on the agentless rules request, so the backend returns only matching flags. Invalid, oversized, or server-ignored selections load every flag and are logged and counted; without the option, the request is unchanged.Risk
Two-way door, scoped to agentless Feature Flags delivery for providers that set the new option. Revert the PR to remove it.
Details
<details><summary>Notes</summary>
White_Space, drops empty values, dedupes, and sorts by UTF-8 bytes. A non-Hash option, a non-Array list, a non-String element, invalid UTF-8, or an option with both the Symbol and the String key for the same list (for exampletags:and"tags") ismalformed_selection.selected_flag_tagsandselected_flag_key_patternsparameters, tags first, RFC 3986 percent-encoded with uppercase hex, appended to the existing query (manageddd_envor a custom base URL's). The whole request URL must be at most 8192 bytes, otherwise the selection is not sent (too_many_values).?token=abc%) no longer raises: the selection is not sent, and the drop is logged and counted astoo_many_valueswith the URL limit text. This is a known limitation for that edge case.flag_selection was not sent (<reason>: <limit>). Loading the full flag configuration.once per provider init, andflag_selection was ignored by the server (<reason>). Loaded the full flag configuration.once per process per reason, after the configuration is applied. Themalformed_selectionlimit text isflag_selection must be a Hash with optional tags and key_patterns string arrays.DD-Flag-Selection-Ignoredis read only on a 200 to a request that carried a selection; anything other than a byte-exact known reason of at most 32 bytes isunknown.flag_selection.droppedandflag_selection.ignoredcounts in thetracersnamespace, tagged withreason, once per process per reason.flag_selection.droppedfor its own process.flag-selection/selection-vectors.jsonfrom DataDog/ffe-system-test-data at the repo's fixture pin (1ae3eda). The 38sdkcases run; the 6rawQuerycases test server-side percent-decoding and have no SDK expectation. The fixture download keepsflag-selection/and caches undertmp/ffe-system-test-data/v2, so a cache written without that directory is not reused.</details>
Validation:
The system-tests and CI results are at the current head,
5cf49939269b4283fb3c7bffb3a8cf7a26adf207. The local spec and type-check runs are at26dc8446e4956cf4bccb8507be06d18adad7f3a0, in the CI images (ghcr.io/datadog/images-rb/engines/ruby:3.1-gnu-gccandruby:4.0-gnu-gcc); the head differs from26dc844only inlib/datadog/open_feature/activation.rb,lib/datadog/open_feature/configuration/flag_selection.rb,spec/datadog/open_feature/activation_spec.rb,spec/datadog/open_feature/flag_selection_reporter_spec.rb, anddocs/GettingStarted.md.5cf49939269b4283fb3c7bffb3a8cf7a26adf207:- Suite:
tests/parametric/test_ffe/test_flag_selection.pyfrom DataDog/system-tests at24a28b649fb74c109ee0401f5051ef89c8009ff9(main; the file is unchanged since DataDog/system-tests#8304 merged).- Library: loaded through
binaries/ruby-load-from-bundle-addcontaininggem 'datadog', git: 'https://github.com/DataDog/dd-trace-rb', ref: '5cf49939269b4283fb3c7bffb3a8cf7a26adf207', require: 'datadog/auto_instrument'. The built image'sGemfile.lockhasrevision: 5cf49939269b4283fb3c7bffb3a8cf7a26adf207, bundler reportedUsing datadog 2.49.0.dev from https://github.com/DataDog/dd-trace-rb (at 5cf4993@5cf4993), and the run reported the library asruby@2.49.0-dev.- Parametric-app wiring, the Ruby part of DataDog/system-tests#8474 applied locally:
server.rbparses the/ffe/startbody, renameskeyPatternstokey_patterns, and passesflag_selection:toDatadog::OpenFeature::Provider.newonly when the field is present.- Build:
docker build --progress=plain -t ruby-test-client -f utils/build/docker/ruby/parametric/Dockerfile ., the same commandrun.shruns. It is a separate step here because the image islinux/amd64and, built under emulation on an arm64 host, it takes longer thanrun.sh's 10-minute build timeout.- Run:
TEST_LIBRARY=ruby ./run.sh PARAMETRIC --skip-parametric-build -F tests/parametric/test_ffe/test_flag_selection.py tests/parametric/test_ffe/test_flag_selection.py.- Result: 12 passed, 0 failed, 0 skipped. That is 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 of
tests/parametric/test_ffe/without-F, same image:TEST_LIBRARY=ruby ./run.sh PARAMETRIC --skip-parametric-build tests/parametric/test_ffe/, 82 passed, 25 skipped, 12 xfailed, 32 xpassed, 0 failed.- The suite's manifest entry for this library is still
missing_feature, and the parametric-app wiring lands in a separate system-tests PR, so PR CI cannot show this run yet.gemfiles/ruby_3.1_openfeature_latest.gemfile, at26dc844:bundle exec rake spec:open_feature, 1509 examples, 0 failures.gemfiles/ruby_3.1_openfeature_min.gemfile, at26dc844:bundle exec rake spec:open_feature, 1509 examples, 0 failures.26dc844:bundle exec rspec spec/datadog/open_feature/configuration/flag_selection_spec.rb -e 'with the shared selection vectors', 38 examples (everysdkcase offlag-selection/selection-vectors.jsonat DataDog/ffe-system-test-data1ae3eda), 0 failures. The 6rawQuerycases have no SDK expectation.gemfiles/ruby-4.0.gemfile, at26dc844:bundle exec rake 'steep:check[--jobs=4]', "No type error detected".5cf4993: 427 check runs pass and 3 are skipped, includingsteep/check,rubocop/lint,standard/lint, andall-jobs-are-green; all 30 GitLab commit statuses pass.5cf49939, in an internal staging test application: the application installed the gem built from this commit (every library file in the installed gem matched the commit), and all 12 cases passed. Tag, key-pattern and combined selections returned exactly the expected flags, a non-matching tag returned none, and values were trimmed and sent in UTF-8 byte order. For more than 31 tags, a key pattern over 200 bytes, and a null element, the provider did not send the selection, logged oneflag_selection was not sent (<reason>)error, and loaded the full configuration. The test-proxy request checks (server-ignored header) were not run in this pass.0f75746eb4b36a69ef91f11130d51d4c816822da, an earlier head of this branch: a test app builds the provider with each selection against the staging backend. 12/12 cases pass direct, and 14/14 pass through a recording proxy that also checks the exact query the SDK sent. As a negative control, master7feafb81, which has agentless delivery but no selection option, loads every flag for all 8 selection cases (the published 2.43.0 predates agentless delivery). Ruby has no lone-surrogate case: its JSON parser rejects one before the SDK sees it.