Skip to content

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

Closed as not planned
mouse114514/opencode
#1

Description

@mouse114514
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

When the opencode config file (opencode.json / opencode.jsonc) contains a root-level field that is not defined in the Config schema (e.g., "files": {}), opencode throws ConfigInvalidError and refuses to load all sessions.

The Config JSON Schema uses "additionalProperties": false at the root level, so any unrecognized property causes a fatal validation error. This is overly fragile: a single misplaced key should produce a warning, not crash the entire application.

Suggested approach:

  1. Unknown properties should be logged as warnings and skipped (warn-and-skip)
  2. Either relax additionalProperties at the root level, or explicitly ignore unrecognized fields during config parsing
  3. If a config section is invalid, skip that section and continue with defaults for the rest
  4. Show a non-blocking notification ("Unknown config field 'files' – ignoring") instead of crashing session loading

Activity

  1. changed the title [-]Config schema should tolerate unknown fields instead of failing all session loading with ConfigInvalidError[/-] [+][FEATURE]: Config schema should tolerate unknown fields instead of failing all session loading[/+] on Jun 21, 2026
  2. Necmttn commented on Jun 21, 2026

    @Necmttn

    The config loader should produce partial config plus structured warnings. Unknown root keys can emit config.warning with JSON path, schema version, and ignored value type; invalid known sections can fall back to defaults for that section.

    Session loading should only fail for errors that make runtime unsafe, such as malformed JSON or invalid required provider credentials. A regression should prove one stray root key does not block session list, resume, or new-session creation.


    Generated with ax.

  3. mouse114514 commented on Jun 22, 2026

    @mouse114514
    Author

    This isn't hypothetical — we have concrete evidence. In the current stable code (packages/opencode/src/config/parse.ts:40-47), topLevelExtraKeys() throws an InvalidError with code "unrecognized_keys" for any root-level key not in the Config schema:

    const extra = topLevelExtraKeys(schema, data)
    if (extra.length) {
      throw new InvalidError({
        issues: [{
          code: "unrecognized_keys",
          keys: extra,
          message: `Unrecognized key${...}: ${extra.join(", ")}`,
        }]
      })
    }

    We had a config file with "files": {} at root level, which is not a known Config key — this immediately blocked all session loading. The schema has no index signatures, so any stray key triggers the error.

  4. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions