fix: tolerate unrecognized config keys instead of failing all session loading - #1
Open
mouse114514 wants to merge 1 commit into
Open
fix: tolerate unrecognized config keys instead of failing all session loading#1mouse114514 wants to merge 1 commit into
mouse114514 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. Fixesanomalyco#33196
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 freeto 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.
Description
When
opencode.json/opencode.jsonccontains root-level fields not defined in the Config schema (e.g.,"files": {}), opencode throwsConfigInvalidErrorand refuses to load all sessions. This is overly fragile — a single misplaced key should produce a warning, not crash the entire application.Change
Instead of throwing
InvalidErrorwith"unrecognized_keys"whentopLevelExtraKeys()finds unknown properties, the fix logs a warning viaconsole.warn()and strips the extra keys from data before passing to Effect Schema validation.This means:
ConfigInvalidErrorcrashes from stray keysRelated Issue
Fixesanomalyco#33196
Verification
"files": {}at root level: previously crashed with ConfigInvalidError, now ignored with warning