Skip to content

Fix config load error reporting and modernize the zod schema - #416

Open
johncarmack1984 wants to merge 2 commits into
jbolda:mainfrom
johncarmack1984:config-error-reporting
Open

Fix config load error reporting and modernize the zod schema#416
johncarmack1984 wants to merge 2 commits into
jbolda:mainfrom
johncarmack1984:config-error-reporting

Conversation

@johncarmack1984

Copy link
Copy Markdown
Contributor

First pass at the types/zod lane. Two independent commits.

The try in configFile wraps JSON.parse and the schema parse together and hands whatever comes out to fromZodError, which only accepts a ZodError. A trailing comma in config.json, or a packages.*.path that isn't there (the statSync inside packageConfigSchema's transform), reports this instead of the actual problem:

Invalid zodError param; expected instance of ZodError. Did you mean to use the "fromError" method instead?

fromError takes unknown, formats a ZodError identically, and passes anything else through with its own message. Three tests cover it: the JSON syntax error, the transform's ENOENT, and a schema violation to pin the zod formatting that was already correct.

Second commit is zod v4 object idioms — .passthrough() and z.string().url() are @deprecated in the installed 4.4.3, and .strict() reads as z.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.

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.
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 74ba842

There are 1 changes which include @covector/files with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
covector 0.13.0 0.13.1
@covector/apply 0.11.0 0.11.1
@covector/assemble 0.13.0 0.13.1
@covector/changelog 0.13.0 0.13.1
@covector/files 0.9.0 0.9.1
action 0.13.0 0.13.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant