-
Notifications
You must be signed in to change notification settings - Fork 1
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
Environment Variables are somewhat case sensitive...? #153
Comments
Since Gestalt supports multiple config sources that have varying cases we normalize all configs to lower case as we build an internal tree. The input sources such as Env Vars are case sensitive, but we create a path by tokenizing it and converting it to lower case. We need to enforce some limitations internally, such as we cant have duplicate nodes or a node can not be of multiple types, such as a leaf and a object. I will check the documentation and see if i can make it more clear. The docs are already long and i didnt want to get to specific, but it may be needed. Duplicate nodes
A path is multiple types, my.path has both a value making it a leaf, and a sub path making it a object. This is prevented.
Unfortunately, it is too difficult to check for similar values and merge them here, so i will leave it as an error. This error covers both cases. I have updated the error message, it is still not great, and i will think about it a little more. but hopefully it is more clear, as i added the duplicate paths cause. It also includes the path to help with investigating. Updated error:
|
I am not creating a new release right now. So there is no way to validate this for now. |
I also updated the config-tree documentation to be a little more clear about when it converts to lower case and the errors that can occur. |
The updated message will help a lot already, I think. 👍 [For the merging, in my specific case I now scan the ProcessBuilder's Environment Map for any key, that is equalIgnoreCase to one I'm creating at runtime, and then use the existing keys exact spelling, so that it matches all possible cases, the user might have entered for the main process. This prevents me from having this weired state... ] |
Hi,
I came across a weird situation, where I have had two environment variables with the same key, but different capitalizations (prefix or path is not relevant, for example PREFIX_A_B and PREFIX_a_B). So, obviously, this is not a correct environment and I will catch this case, but the Exception was quite misleading at first...
Maybe something like ' for path x.y.z there were different values in same source' or something like that would be better? And if values are the same, just merge both...?
(Hint for debugging: In IntelliJ, if you specify the environment, duplicate variables even with different cases will get stripped. But with ProcessBuilder, it's possible to create such malformed environments.)
Additional Note: my expectation of case-insensitivity comes from the first sentence of this paragraph:
https://github.com/gestalt-config/gestalt#getconfig-path-options
The text was updated successfully, but these errors were encountered: