Skip to content

RequestHeaders option not binding correctly from config #128

Description

@skwasjer

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"]

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions