Skip to content

feat: make use of flagd-selector header in RPC mode#396

Merged
toddbaert merged 7 commits into
mainfrom
feat/rpc-flagd-selector-header
Jun 2, 2026
Merged

feat: make use of flagd-selector header in RPC mode#396
toddbaert merged 7 commits into
mainfrom
feat/rpc-flagd-selector-header

Conversation

@toddbaert
Copy link
Copy Markdown
Member

@toddbaert toddbaert commented Jun 1, 2026

  • The in-process resolver already sends the flagd-selector gRPC metadata header, but the RPC resolver did not. This PR wires it up: the RPC resolver now sends the header on every unary call and on the EventStream when a selector is configured, so the flagd server can serve the requested flag set.
  • Brings the Python RPC resolver to parity with the Java and JS providers, which both already wire this header up (see flagd issue #1814).
  • Additive: behavior is unchanged when no selector is configured.

We missed the RPC mode in: #320 (closed #319).

@toddbaert toddbaert requested review from a team as code owners June 1, 2026 19:03
@github-actions github-actions Bot requested review from aepfli and federicobond June 1, 2026 19:03
@toddbaert toddbaert requested a review from gruebel June 1, 2026 19:03
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for flagd selectors in the gRPC resolver by appending the flagd-selector metadata header to both unary and event stream calls when configured, and includes unit tests for unary calls. The feedback recommends updating GrpcMultiCallableArgs in types.py to avoid type-checking failures, importing the FLAGD_SELECTOR_HEADER constant in tests to avoid hardcoding, and adding test coverage for the event stream (listen) code path.

Comment thread providers/openfeature-provider-flagd/tests/test_grpc_resolver.py
Comment thread providers/openfeature-provider-flagd/tests/test_grpc_resolver.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.28%. Comparing base (c4b4257) to head (b187b10).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #396      +/-   ##
==========================================
+ Coverage   94.20%   96.28%   +2.08%     
==========================================
  Files          31       47      +16     
  Lines        1070     1750     +680     
==========================================
+ Hits         1008     1685     +677     
- Misses         62       65       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@toddbaert toddbaert changed the title feat: RPC resolver sends flagd-selector header feat: make use of flagd-selector header in RPC mode Jun 1, 2026
toddbaert added 4 commits June 1, 2026 15:30
RPC resolver now attaches the `flagd-selector` gRPC metadata header on every unary call and on the EventStream when a selector is configured, so the flagd server can serve the requested flag set. Brings the Python RPC resolver to parity with the Java and JS providers.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
… args helper

Reduces listen() complexity below ruff C901 threshold while keeping the flagd-selector header wiring intact.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
The flagd evaluation v2 generated stubs require grpcio>=1.81.0 (RuntimeError at import time otherwise). The pyproject constraint and lockfile were still pinned to 1.80.0, breaking CI on main.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
- types.py: metadata is now variadic tuple[tuple[str, str], ...] to allow >1 entry and satisfy mypy.\n- tests: import FLAGD_SELECTOR_HEADER from the resolver instead of hardcoding, and add coverage for the EventStream listen() path (both with and without selector).

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert force-pushed the feat/rpc-flagd-selector-header branch from 07be9e3 to 7ca797b Compare June 1, 2026 19:31
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the grpcio dependency and adds support for passing a selector header (flagd-selector) in gRPC metadata for both unary calls and event streams in the flagd provider, along with comprehensive unit tests. The feedback suggests a minor improvement in GrpcResolver.__init__ to use the config parameter directly instead of self.config to prevent potential initialization issues and maintain consistency.

toddbaert and others added 2 commits June 1, 2026 15:39
…rovider/flagd/resolvers/grpc.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Copy link
Copy Markdown

@JamieSinn JamieSinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concerns

@toddbaert toddbaert merged commit e1c3c6a into main Jun 2, 2026
60 checks passed
@toddbaert toddbaert deleted the feat/rpc-flagd-selector-header branch June 2, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flagd] Update selector handling for consistency with sync, evaluation, and OFREP services

5 participants