Different casing in variables causes exception
See original GitHub issueCase
Add the same configuration key value pair to from different configuration sources using different casing.
Expected result
Configuration value from last configuration source is the value present in the final configuration.
The documentation states that
Configuration keys are not case-sensitive
and
Configuration sources are read in the order that they’re specified. In the preceding code, the environment variables are read last. Any configuration values set through the environment replace those set in the two previous providers.
Actual result
ArgumentException
with the message An item with the same key has already been added
is thrown.
Sample program
var configurationRoot = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string>
{
{"CASE:PROBLEM", "black magic"}
})
.AddInMemoryCollection(new Dictionary<string, string>
{
{"case:PROBLEM", "white magic"}
})
.Build();
var newconfigurationRoot = new ConfigurationBuilder()
.AddInMemoryCollection(configurationRoot.AsEnumerable())
.Build();
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Detect Responsible variable for a Java Exception
To my knowledge there's no way to inspect an exception to determine which variable caused the error (I wish it were true for...
Read more >What is the reason for using lowercase for the first word in ...
Local variable and methods that return a value should have the first word in lowercase like int employeeCount = getEmployeeCount() . However, I ......
Read more >Exceptional Naming. When code throws or catches an…
The reason naming is both hard and important is because it is an act of communication; without good names your code might as...
Read more >8. Errors and Exceptions — Python 3.11.4 documentation
When an exception occurs, it may have associated values, also known as the exception's arguments. The presence and types of the arguments depend...
Read more >Errors and Exceptions
A list of compile-time errors and warnings, runtime errors in Erlang. Also errors, exits and throws then how to handle them with try...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We didn’t recover from this. Until this is fixed we educate our developers to make sure to use lower casing for all settings 😢
Use case: We pull settings from multiple sources, e.g. Consul, environment variables, appsettings.json, command line, Vault etc. in order to give both developers and site operations maximum flexibility. Keeping casing of settings across all these sources was a pain until we decided to merely use lowercase for everything.
Fixed by https://github.com/aspnet/Extensions/pull/503