-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fixes environment variable prefixes with double underscores preventing environment variables from being parsed #42932
Conversation
The fix implementation works like so: - The environment variable prefix is stripped from a variable name. - The variable name is then normalized. - The prefix is then prepended to the variable name. - Additionally, the filtering now occurs at the same time as parsing/transformation.
Tagging subscribers to this area: @maryamariyan |
I should mention: this PR also supersedes #41092, the author of which appears to be inactive. |
...tensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we support more than double _
?
This PR simply prevents normalization of the prefix. Number of underscores doesn't matter. So long as it's part of the prefix, it will not be normalized. |
I should also point out, that the error here occured due to the fact that normalization of variable name happened before the user-specified prefix was fixed, which led to situations where if variables were prefixed with a string that contained a double-or-longer underscore substring, it was normalized, and then no longer matched the prefix, which meant the variables weren't loaded. The fix was to simply swap the order of those operations. |
@maryamariyan what is the next step here? this one seems to have got stuck. 😃 |
...tensions.Configuration.EnvironmentVariables/src/EnvironmentVariablesConfigurationProvider.cs
Outdated
Show resolved
Hide resolved
Overall, looks good, @maryamariyan and I left some comments. Also, merge conflicts need to be addressed. |
...es/Microsoft.Extensions.Configuration.EnvironmentVariables/tests/EnvironmentVariablesTest.cs
Outdated
Show resolved
Hide resolved
I shall address the changes later this week, possibly today |
I am stuck with a problem: I am either misunderstanding something or #44923 altered the behaviour of loading SQL connection strings: Prior to #44923, adding a connectionstring-prefixed envvar to the collection would yield it back in the configuration with |
Nevermind above, I have tested above and it seems I misunderstood. |
I apologize for the slight mess in commits, however git is refusing to recognize that I've merged a change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hello @safern! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
This PR fixes #40911.
The following changes are implemented:
AzureEnvToAppEnv
now filters out variables which do not start with any of the valid prefixes.Relevant tests have been added to the repository. All passing.