-
Notifications
You must be signed in to change notification settings - Fork 10.3k
AddHeaderPropagation()
without providing Action<HeaderPropagationOptions> configureOptions
prevents middleware from working correctly
#48581
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
Comments
@jjanuszkiewicz Did you register the middleware? also an example in this repo: https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/HeaderPropagation/samples/HeaderPropagationSample/Startup.cs |
Yes, I register the middleware. The problem is that:
My suggestion 2 would address that:
|
Like I said, I can create a PR with proposed changes and hopefully also with some tests demonstrating the problem, but I'd like to get some feedback first (e.g. if this is for some reason by design and the PR won't be considered for merging?) |
API changes require an API proposal and review and number 1 is a non-starter because it's a binary breaking change. |
I am seeing this as well. I was expecting |
If I have some spare time during holiday, I'll create a MR with tests showing the problem and maybe a possible solution (#2 from my original post). If time permits. |
I fell for this too. This behavior to me is very unintuitive, and unflexible. |
Is there an existing issue for this?
Describe the bug
When trying to configure the header propagation feature using the
HeaderPropagationServiceCollectionExtensions.AddHeaderPropagation(this IServiceCollection services)
(link) method, there is no
HeaderPropagationOptions
instance registered, so the middleware doesn't capture any headers and header propagation won't work, even when header names are specified for a specificHttpClient
, e.g.:This results in no headers being forwarded.
Instead, this needs to be done:
This is especially problematic if different
HttpClient
s require forwarding different headers - theservices.AddHeaderPropagation
call needs to list all those headers, which is code duplication and leads to bugs.I propose to either:
AddHeaderPropagation(this IServiceCollection services)
internal, as it's useless for users of this library. This way all headers still need to be listed explicitly in theservices.AddHeaderPropagation()
call, but at least the not working method is hidden.AddHeaderPropagation(Action<HeaderPropagationMessageHandlerOptions>)
so that it adds the configured headers to the registeredHeaderPropagationOptions
(and/or registers it if it's not yet registered).I can create a PR for either of these (I prefer option 2), but looking for some feedback first.
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: