Skip to content
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

RequestHeaders option not binding correctly from config #128

Closed
skwasjer opened this issue Dec 17, 2024 · 0 comments · Fixed by #129
Closed

RequestHeaders option not binding correctly from config #128

skwasjer opened this issue Dec 17, 2024 · 0 comments · Fixed by #129
Labels
bug Something isn't working

Comments

@skwasjer
Copy link
Owner

skwasjer commented Dec 17, 2024

When binding CorrelateOptions via env var or JSON, it is not correctly 'overwriting' the default value.

Actual

IConfigurationRoot config = new ConfigurationBuilder()
    .AddInMemoryCollection(
        new Dictionary<string, string?>
        {
            { "RequestHeaders:0", "Header1" },
            { "RequestHeaders:1", "Header2" }
        }
    )
    .Build();

using ServiceProvider services = new ServiceCollection()
    .Configure<CorrelateOptions>(config.Bind)
    .BuildServiceProvider();

CorrelateOptions opts = services.GetRequiredService<IOptions<CorrelateOptions>>().Value;

opts.RequestHeaders here contains ["X-Correlation-Id", "Header1", "Header2]". Effectively, the configured values are appended instead of overwriting the default value.

Expected

The RequestHeaders to only contain the configured values ["Header1", "Header2"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant