question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different casing in variables causes exception

See original GitHub issue

Case

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.

image

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:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rasmuscommented, Oct 12, 2018

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.

0reactions
ajcvickerscommented, Nov 15, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found