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"]
When binding
CorrelateOptionsvia env var or JSON, it is not correctly 'overwriting' the default value.Actual
opts.RequestHeadershere contains["X-Correlation-Id", "Header1", "Header2]". Effectively, the configured values are appended instead of overwriting the default value.Expected
The
RequestHeadersto only contain the configured values["Header1", "Header2"]