Skip to content

fix: tolerate unrecognized config keys instead of failing all session loading - #1

Open
mouse114514 wants to merge 1 commit into
devfrom
fix/config-tolerate-unknown-keys
Open

fix: tolerate unrecognized config keys instead of failing all session loading#1
mouse114514 wants to merge 1 commit into
devfrom
fix/config-tolerate-unknown-keys

Conversation

@mouse114514

Copy link
Copy Markdown
Owner

Description

When opencode.json / opencode.jsonc contains root-level fields not defined in the Config schema (e.g., "files": {}), opencode throws ConfigInvalidError and 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 InvalidError with "unrecognized_keys" when topLevelExtraKeys() finds unknown properties, the fix logs a warning via console.warn() and strips the extra keys from data before passing to Effect Schema validation.

This means:

  • Unknown config keys are silently ignored (with a console warning)
  • All valid portions of the config continue to apply normally
  • No more ConfigInvalidError crashes from stray keys

Related Issue

Fixesanomalyco#33196

Verification

  • Unknown key "files": {} at root level: previously crashed with ConfigInvalidError, now ignored with warning
  • Valid configs continue to work exactly as before
  • Only top-level keys are affected; sub-object validation remains strict

… 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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Config schema should tolerate unknown fields instead of failing all session loading

1 participant

@mouse114514