Skip to content

fix: handle invalid config gracefully in info/logs/open/db-list/watch#23

Merged
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:fix/graceful-config-errors
Jun 7, 2026
Merged

fix: handle invalid config gracefully in info/logs/open/db-list/watch#23
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:fix/graceful-config-errors

Conversation

@kjellbergzoey

Copy link
Copy Markdown
Contributor

Problem

After zod validation was added, readProjectConfig() / readLocalConfig() (src/lib/config.ts) now throw when kiqr.yaml / config.yaml exists but is invalid (bad YAML or schema mismatch). Several commands call these without a try/catch, so they crash with an unhandled error and a raw stack trace instead of showing the friendly message.

Affected commands: info, logs, open, db list, watch.

(up/down/restart/destroy already route config errors through StepRunner; wp is addressed separately.)

Fix

Wrap the config read(s) in each affected command in try/catch and surface the error via that command's existing error path:

  • info.tsx — renders a red error Text and exits with an error (the component reads config in its render body).
  • logs.tsx, open.tsxconsole.error(message) + exit(new Error()), matching their existing "not initialized" handling.
  • db/list.tsxsetError(message) + exit(new Error()).
  • watch.tsxsetError(message) into its existing error Box.

Each keeps the existing "not initialized" (null config) behavior intact.

Tests

The lib-level tests/lib/config.test.ts already asserts that readProjectConfig/readLocalConfig throw clear errors on malformed YAML, missing fields, and wrong field types (for both project and local config), which is the behavior these commands now handle. The command files are Ink components; no brittle UI tests were added.

Gates

  • npm run typecheck
  • npm test ✅ (192 passed)
  • npm run build
  • npm run lint

🤖 Generated with Claude Code

After zod validation was added, readProjectConfig/readLocalConfig throw
when kiqr.yaml or config.yaml exists but is invalid (bad YAML or schema
mismatch). Several commands called these without try/catch and crashed
with an unhandled error instead of showing the message.

Wrap the config reads in info, logs, open, db list, and watch in
try/catch and surface the error through each command's existing error
path, matching how each file already reports the "not initialized" case.

The lib-level config tests already assert readProjectConfig/readLocalConfig
throw clear errors on invalid YAML and schema mismatches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kjellberg
kjellberg merged commit a43b1c4 into kiqr:main Jun 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants