fix: avoid overwriting malformed global config#1339
Conversation
Hweinstock
left a comment
There was a problem hiding this comment.
Thanks for taking a look! Looking at this change, we might need a broader refactor here to get the right behavior we're looking for.
There was a problem hiding this comment.
it looks like this catch will still silently swallow all errors from downstream. The result is that the user won't see a helpful error message of why the command failed when their config is invalid, but will see that the command failed.
I think this might take a broader refactor to bubble up this error correctly, (and maybe unify these read config methods)
|
That makes sense. This patch handles the overwrite case, but it still leaves callers without a clean way to distinguish a missing config from a malformed config. I can rework this around returning the parse/read error from the config-loading path if that matches the direction you had in mind. |
Return a {success, error} result instead of a bare boolean so callers can distinguish a missing config (start fresh) from a malformed one (left unchanged, with the parse/read error surfaced). Telemetry enable/disable now report the actual failure reason rather than a generic write warning.
|
Reworked along those lines. |
Summary
Fixes #1337.
Testing
npx prettier --check src/lib/schemas/io/global-config.ts src/cli/__tests__/global-config.test.tsnpx vitest run --project unit src/cli/__tests__/global-config.test.ts