Skip to content

Config: reject unknown keys, bad widths, non-http origins, blank selectors - #120

Merged
tmashara merged 1 commit into
mainfrom
claude/config-validation
Nov 2, 2026
Merged

tmashara merged 1 commit into
mainfrom
claude/config-validation

Conversation

@tmashara

@tmashara tmashara commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Config mistakes that used to slip through, or fail later with a misleading error, now exit 2 with the bad key named.

What's validated now

  • Unknown top-level keys exit 2, naming the key and listing the valid ones. This works like the existing check on route-object keys.
  • Unknown masks[i] keys do the same. Before, a urlpath typo silently turned a mask scoped to one route into a global one. Both key lists are type-checked against RenderdiffConfig and Mask (satisfies Record<…>), so they can't drift from the types.
  • widths must be a non-empty array of positive integers. Before, widths: [] crashed with exit 3, and a fractional width failed every shot.
  • Origins: the resolved left/right, from the config or from --left/--right, must be http(s) URLs. Before, localhost:3000 gave a misleading "not responding". renderdiff probe uses the same check.
  • Blank selectors: hideSelectors entries and masks[].selector must be non-empty after trim. The --hide/--mask flags already reject blanks.

Breaking

These configs and flags now exit 2:

  • configs with unknown keys (typos included) at the top level or in masks[i]
  • empty or fractional widths
  • non-http(s) origins, whether from the config or from --left/--right
  • blank hideSelectors entries or mask selectors

A fractional --width flag is not rejected here; the companion flag-parsing PR handles that.

Testing

New --dry-run cases in tests/unit/config-load.test.ts and tests/unit/cli-args.test.ts, one per new error, plus updated message checks for widths and mask selectors. npm run typecheck, lint, format:check and npm test (381/381) all pass.

🤖 Generated with Claude Code

…ctors

Unknown top-level and masks[i] keys exit 2 with the valid keys listed, so a
`urlpath` typo no longer turns a scoped mask global. The key lists are
type-checked against RenderdiffConfig and Mask. widths must be a non-empty
array of positive integers. The resolved left/right (config or flags) must be
http(s) URLs, and probe uses the same check. hideSelectors entries and mask
selectors must be non-blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit 75fbbec into main Nov 2, 2026
3 checks passed
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