fix: preserve last-directory nested secrets precedence for mixed-case names - #969
Open
cpruijsen wants to merge 1 commit into
Open
fix: preserve last-directory nested secrets precedence for mixed-case names#969cpruijsen wants to merge 1 commit into
cpruijsen wants to merge 1 commit into
Conversation
… names Normalize each secrets_dir before merging so last-directory-wins still holds when filenames differ only by case.
Contributor
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This changes production secret-resolution behavior and can alter which sensitive credential value is selected when filenames differ by case. Although the implementation is focused and tested, the sensitive-data implications warrant human review. You can add or adjust custom eligibility rules. Learn more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each directory is now passed through
parse_env_varsbefore the merge, so mixed-case names collide on the same key and a later directory overwrites. That is the same order DotEnvSettingsSource already uses for multiple env files. Fixes #960.When
secrets_diris a list, NestedSecretsSettingsSource is documented as last-directory-wins. Under the default case-insensitive matching, NestedSecretsSettingsSource merged raw filenames first, then lowercased keys. Python dicts keep a key's insertion position when its value is replaced, so directoriesTOKEN=first,token=second,TOKEN=thirdproducedtoken=secondinstead ofthird.Parse then
dict.update, matching_read_env_files. Alternative was keepingreduceand wrappingparse_env_varsin the generator. Can switch if you would rather keepreduce.