Fix config load error reporting and modernize the zod schema - #416
Open
johncarmack1984 wants to merge 2 commits into
Open
Fix config load error reporting and modernize the zod schema#416johncarmack1984 wants to merge 2 commits into
johncarmack1984 wants to merge 2 commits into
Conversation
The catch around config parsing also covers JSON.parse and anything a schema transform throws, but handed those to fromZodError, which only accepts a ZodError. A trailing comma in config.json, or a package path that does not exist, reported "Invalid zodError param" instead of the syntax error or ENOENT. fromError handles both and formats ZodErrors identically.
.passthrough() is deprecated in favor of z.looseObject(), z.string().url() in favor of z.url(), and .strict() reads as z.strictObject(). Same parse results and same inferred types, verified against the previous schema.
Contributor
Package Changes Through 74ba842There are 1 changes which include @covector/files with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
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.
First pass at the types/zod lane. Two independent commits.
The
tryinconfigFilewrapsJSON.parseand the schema parse together and hands whatever comes out tofromZodError, which only accepts aZodError. A trailing comma inconfig.json, or apackages.*.paththat isn't there (thestatSyncinsidepackageConfigSchema's transform), reports this instead of the actual problem:fromErrortakesunknown, formats aZodErroridentically, and passes anything else through with its own message. Three tests cover it: the JSON syntax error, the transform'sENOENT, and a schema violation to pin the zod formatting that was already correct.Second commit is zod v4 object idioms —
.passthrough()andz.string().url()are@deprecatedin the installed 4.4.3, and.strict()reads asz.strictObject. No behavior change; parse results and inferred types checked against the previous schema before the swap.Nothing here changes the config input shape, so it should stay clear of that question.