fix: handle invalid config gracefully in info/logs/open/db-list/watch#23
Merged
Merged
Conversation
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>
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.
Problem
After zod validation was added,
readProjectConfig()/readLocalConfig()(src/lib/config.ts) now throw whenkiqr.yaml/config.yamlexists 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/destroyalready route config errors throughStepRunner;wpis 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 errorTextand exits with an error (the component reads config in its render body).logs.tsx,open.tsx—console.error(message)+exit(new Error()), matching their existing "not initialized" handling.db/list.tsx—setError(message)+exit(new Error()).watch.tsx—setError(message)into its existing error Box.Each keeps the existing "not initialized" (null config) behavior intact.
Tests
The lib-level
tests/lib/config.test.tsalready asserts thatreadProjectConfig/readLocalConfigthrow 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