fix: prevent Zod defaults from overwriting values during config merge#205
Open
ariane-emory wants to merge 2 commits intodevfrom
Open
fix: prevent Zod defaults from overwriting values during config merge#205ariane-emory wants to merge 2 commits intodevfrom
ariane-emory wants to merge 2 commits intodevfrom
Conversation
When parsing partial configs, Zod applies .default() values to missing fields. During config merge (global + project + cli), these defaults would overwrite explicit values from earlier configs. Solution: strip defaults during parsing, apply them only to the final merged result.
0358476 to
f62141d
Compare
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.
Type of change
What does this PR do?
This PR resolves an issue wherein, while merging multiple configuration files (for example, a global and project-local configuration file), if a setting has a default value, the default value is applied immediately after loading the first configuration file, leading to the default value being preferred over a non-default value for the same setting that is present in the second configuration file (for instance, if no
foovalue is present in the first file, but the default value offoois 10, and the second configuration file does contain a value 5 forfoo, the default value 10 will be used instead of the deliberately set value of 5).