opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[Discussion] Make config tolerant of unknown keys for forward compatibility

Open CasualDeveloper opened this issue 3 weeks ago • 8 comments

Problem

Currently, opencode.json uses Zod .strict() validation which rejects unknown config keys. This breaks when using a config file with newer options on an older OpenCode version.

Example scenario: A user has session_delete keybind configured (a newer option). When they run an older OpenCode version that doesn't recognize this key, config validation fails entirely instead of just ignoring the unknown key.

Proposed Solution

Change .strict() to .passthrough() on user-facing config schemas:

  • Keybinds (line 575)
  • Provider (line 636)
  • Info / main config (line 831)

Internal schemas like McpLocal, McpRemote, McpOAuth remain .strict() since they're programmatic, not user-facing.

Additionally, add warning logs for unknown keys so users still get feedback about potential typos while configs from newer versions still work. This addresses the concern from #1081 about catching typos.

Tradeoffs

Pros:

  • Forward compatibility - newer configs work on older versions
  • Better UX when sharing configs across different OpenCode versions
  • Users still get warning feedback about potential typos

Cons:

  • Typos don't cause hard failures (but warnings are logged)

Implementation

Working implementation on branch feat/config-forward-compat at https://github.com/CasualDeveloper/opencode/tree/feat/config-forward-compat


Looking for feedback on whether this approach is acceptable before opening a PR.

CasualDeveloper avatar Dec 25 '25 04:12 CasualDeveloper