fix: tolerate unrecognized config keys instead of failing all session loading#33197
fix: tolerate unrecognized config keys instead of failing all session loading#33197mouse114514 wants to merge 1 commit into
Conversation
… loading When opencode.json/jsonc contains root-level fields not defined in the Config schema, topLevelExtraKeys() throws ConfigInvalidError which prevents all sessions from loading. Changed to log a warning and strip the unknown keys from data before passing to Effect Schema validation. This makes config parsing resilient to stray or misplaced keys. Fixes anomalyco#33196
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR: PR #29208: fix(config): catch parse errors gracefully during startup This PR also addresses graceful error handling during config/session loading, which is conceptually related to your PR #33197's goal of tolerating config issues rather than crashing. However, PR #29208 appears to focus on parse errors during startup, while your PR specifically addresses unrecognized top-level keys in the config schema. These are distinct issues but cover similar concerns about config robustness. You may want to review #29208 to ensure your approach is consistent with existing patterns for graceful config handling. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #33196
Type of change
What does this PR do?
opencode.json/opencode.jsoncroot-level fields not in the Config schema (e.g.,"files": {}) currently throwConfigInvalidErrorand block all session loading. This is fragile — a stray key can crash the entire app.Instead of throwing
InvalidErrorviatopLevelExtraKeys(), the fix logsconsole.warn()for each unrecognized key and strips them from data before Effect Schema validation. Valid config still applies normally.How did you verify your code works?
"files"key from the debug archive — no more crash, warning printed to console"sessions","models") still work correctly after the changeScreenshots / recordings
N/A — this is a backend/config change, no UI.
Checklist