feat(config): tolerate invalid config.toml sections instead of failing startup#689
Conversation
…g startup Schema errors now drop only the offending sections (single entries for providers/models) with a warning, so a typo no longer prevents startup or drops the login state. TOML syntax errors still fail fast with the parse location. Mid-run reloads keep the last good config when the file breaks. Warnings surface via the new getConfigDiagnostics API: as a startup notice in the TUI, on stderr in print mode, and in the status bar after /new. Write paths stay strict so a broken file is never silently rewritten, and now fail with a short actionable message instead of raw validation JSON; the /provider TUI flow and the kimi provider CLI report these errors instead of crashing on an unhandled rejection.
🦋 Changeset detectedLatest commit: 0e6a451 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf480fc0ab
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…sues A providers/models entry with several validation issues was deleted by the first issue, and the remaining issues from the same safeParse pass then escalated to deleting the entire section — one badly-typed custom provider could drop every provider, including the managed OAuth login. Issues on entry-keyed sections now only ever target the entry itself; once it is gone, later issues are no-ops.
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Problem
A single typo in
config.toml(e.g. a wrong value type in[loop_control]) made the app fail to start entirely — including dropping the user into a crash even though their providers, models, and login state were perfectly fine. Mutating settings (/provider,kimi provider) on top of a broken file crashed with an unhandled rejection dumping raw validation JSON.Changes
Lenient runtime loading (
loadRuntimeConfigSafe):providers/models, the whole top-level section otherwise — with a warning. Login state survives a typo elsewhere in the file.KIMI_MODEL_*env overlay is skipped with a warning instead of throwing.Warning surfacing via the new
getConfigDiagnosticsAPI: startup notice in the TUI, stderr in print mode, status bar after/new.Write paths stay strict — read-merge-write must never use a salvaged config as its base, or rewriting would silently drop the user's broken-but-fixable sections. They now fail with a short actionable message ("fix it first, run
kimi doctor") instead of raw validation JSON, and:/providerTUI flow reports errors in the status bar instead of crashing on a dangling promise;kimi providerCLI prints one line and exits 1 instead of an unhandled-rejection stack dump;resolveManagedAuth) reads leniently so a broken section elsewhere doesn't break OAuth-backed sessions.Testing
fileErrorsemantics, keep-last-good reloads, write rejection message and file integrity, CLI error boundary.[loop_control]with a real OAuth login starts with a warning and a working session;[[[fails fast with the parse location;kimi provider removeon a broken file prints one actionable line.