feat: add custom headers support for sync providers#1955
Closed
raflFaisal wants to merge 6 commits intoopen-feature:mainfrom
Closed
feat: add custom headers support for sync providers#1955raflFaisal wants to merge 6 commits intoopen-feature:mainfrom
raflFaisal wants to merge 6 commits intoopen-feature:mainfrom
Conversation
✅ Deploy Preview for polite-licorice-3db33c canceled.
|
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to specify custom headers for HTTP and gRPC sync providers, either globally via a new CLI flag and environment variable or per-source in the configuration. The implementation correctly handles header merging and application to outbound requests, including special logic for the HTTP Host header. A compilation error was identified in the unit tests where the NewHTTP function is called with an incorrect number of arguments.
Add --sync-provider-headers CLI flag and per-source headers configuration to inject custom HTTP headers and gRPC metadata into outbound sync requests. This enables use cases like interop gateway routing and tenant identification. Per-source headers take precedence over global headers for conflicting keys. Signed-off-by: raflFaisal <faisal.rafi.mca@gmail.com>
e6b2f35 to
4a0d2e0
Compare
Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
Removed an empty line for cleaner code. Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
Signed-off-by: faisal.rafi <faisal.rafi.mca@gmail.com>
|
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.



Summary
Add support for custom headers in sync providers (HTTP and gRPC), configurable both globally via CLI flag and per-source in JSON configuration.
Problem
flagd's sync providers cannot inject custom request headers into outbound requests. This limits integration with environments where intermediaries (API gateways, reverse proxies, service meshes) require specific headers for routing, tenant identification, or policy enforcement, resulting in errors like 421 Misdirected Request or misrouting.
Solution
CLI flag: --sync-provider-headers="Key=Value,Key2=Value2" injects headers into sync requests.
Per-source config: "headers": {"Key": "Value"} in the source JSON for fine-grained control.
Per-source values take precedence over global values for conflicting keys.
HTTP:
flagd start --sync-provider-headers="X-Gateway-Host=myhost,X-Tenant-ID=tenant1"
--sources='[{"uri":"http://my-flags.com/flags","provider":"http"}]'
GRPC:
flagd start --sources='[{"uri":"proxy-gateway-server.xyz.com", "provider":"grpc","selector":"features","headers":{"X-Routing-Target-Host":"b.flags-server.service"}}]'
Headers are sent as HTTP request headers for HTTP sync and as gRPC metadata for gRPC sync.
Scope & compatibility
Fully backward compatible, i.e. headers are optional and default to empty
No behavior change for existing configurations
Covers both HTTP and gRPC sync providers