Repository navigation
Validate --settings-json with zod - #3106
Merged
Merged
Conversation
Previously any key/value from --settings-json was written straight into the config store (with a `todo use zod?`), so a typo or bad value could corrupt the config file. Define the config as a zod schema in common/types (Config and its member types are now inferred from it, unchanged) and validate the CLI settings against it: unknown keys or invalid values are logged and nothing is applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125XTBqSHMdXYaSLkahs1Xr Co-authored-by: Mikael Finstad <finstaden@gmail.com>
A JSON5 syntax error threw out of init(), so the window was never created. Parse inside the zod pipeline so it's logged and ignored like other invalid settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125XTBqSHMdXYaSLkahs1Xr Co-authored-by: Mikael Finstad <finstaden@gmail.com>
mifi
force-pushed
the
claude/settings-json-zod
branch
from
October 15, 2026 02:48
f99ca0b to
4c2c047
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.
Resolves the
// @ts-expect-error todo use zod?insrc/main/index.ts.Previously every key/value from
--settings-jsonwas written straight into the config store, so a typo or invalid value could corrupt the config file (as the docs warned).src/common/types.ts:Configand its member types (KeyboardAction,KeyBinding,CaptureFormat, โฆ) are now defined as zod schemas, with the TS types inferred from them. The inferred types are identical to the old hand-written ones; I verified this with a strict type-equality check against the previous definitions. No importers needed changes.src/main/util.ts:parseSettingsJson()=configSchema.partial().strict()on the JSON5 input.src/main/index.ts: on invalid settings, log a readable error (z.prettifyError) and apply none of them; the app keeps starting normally.docs/cli.md: replaced the "could corrupt your configuration file" warning.Behaviour change: unknown keys (e.g. typos) are now rejected instead of silently stored.
๐ค Generated with Claude Code
https://claude.ai/code/session_0125XTBqSHMdXYaSLkahs1Xr
Generated by Claude Code