-
Notifications
You must be signed in to change notification settings - Fork 93
feat: normalize selector in sync (use header as in OFREP and RPC) #1815
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
Conversation
✅ Deploy Preview for polite-licorice-3db33c ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
/Gemini review |
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.
Code Review
This pull request normalizes selector handling in the sync service to align with other services, prioritizing the Flagd-Selector header while maintaining backward compatibility with the request body selector. The changes are well-implemented and include comprehensive tests for all scenarios. My review includes a few suggestions to refactor the new logic and test code for improved maintainability and to reduce duplication.
89372a9 to
65f9b6a
Compare
|
/gemini review |
|
I pushed some changes in tests and reverted the go.mod/sum files. I manually tested this and it works as expected. |
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.
Code Review
This pull request successfully normalizes selector handling in the sync service by prioritizing the Flagd-Selector header over the request body, which aligns it with other services. The implementation is backward compatible and includes new tests. My review focuses on two main points: ensuring the deprecation warning for the body selector is logged at an appropriate level (Warn instead of Debug) and enhancing the tests to verify that this warning is correctly emitted. These changes will improve user guidance and test coverage.
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Co-authored-by: aepfli <9987394+aepfli@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
b597dae to
a968b90
Compare
|



Problem
Currently, flagd services have inconsistent handling of selectors:
selectorfield from the request bodyFlagd-SelectorheaderFlagd-SelectorheaderThis inconsistency makes the API surface less predictable and can lead to confusion for users.
Solution
This PR normalizes selector handling by updating the sync service to accept the
Flagd-Selectorheader as the primary method, aligning it with the evaluation and OFREP services. The implementation maintains full backward compatibility by falling back to the request body selector when the header is not present.Changes
Core Implementation
Modified
flagd/pkg/service/flag-sync/handler.go:getSelectorExpression()helper method that checks forFlagd-Selectorheader (via gRPC metadata) firstselectorfield if header is not presentSyncFlags()andFetchAllFlags()methodsTest Coverage
Added 5 comprehensive test cases in
handler_test.go:All existing tests continue to pass.
Migration Path
The change is fully backward compatible. Users can migrate at their convenience:
Current (deprecated):
Recommended:
Benefits
Flagd-Selectorheader patternBreaking Changes
None. The request body selector will be removed in a future major version (e.g., v2.0.0).
Related
Addresses #[issue_number]
Original prompt
Fixes #1814
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Relates to: open-feature/flagd-schemas#199