Skip to content

Conversation

@kaizen403
Copy link
Contributor

@kaizen403 kaizen403 commented Feb 11, 2026

fixes #1767

summary
a single invalid field in oh-my-opencode.json (e.g. wrong type for prometheus.permission.edit) caused safeParse to fail on the whole object, silently replacing the entire config with {}. all agent model overrides, categories, and disabled hooks were lost with no useful indication.

root cause
loadConfigFromPath used OhMyOpenCodeConfigSchema.safeParse() on the full raw config. if any field failed validation the function returned null, and the caller fell back to {}.

changes

  • added parseConfigPartially() that tries the full parse first (fast path), then falls back to validating each top-level key independently — keeping sections that pass, dropping ones that fail
  • loadConfigFromPath now falls back to partial parsing instead of returning null on validation failure
  • invalid sections are logged with details so users can fix them
  • added tests covering: fully valid, partially invalid, completely invalid, empty, and unknown-key configs

testing

  • bun test src/plugin-config.test.ts — 11 pass
  • bun run typecheck — clean
  • bun test — 2200 pass, 10 pre-existing fail (mcp-oauth network tests)

Summary by cubic

Prevented full config loss when one field is invalid by validating config sections independently and keeping the valid parts. Invalid sections are logged so users can fix them.

  • Bug Fixes
    • Added parseConfigPartially() to validate each top-level key and build a partial config.
    • loadConfigFromPath now falls back to partial parsing on validation errors instead of returning null.
    • Logs detailed errors for skipped sections; unknown keys are ignored.
    • Added tests for fully valid, partially invalid, completely invalid, empty, and unknown-key configs.

Written for commit d3978ab. Summary will update on new commits.

… discard the entire config

Previously, a single validation error (e.g. wrong type for
prometheus.permission.edit) caused safeParse to fail and the
entire oh-my-opencode.json was silently replaced with {}.

Now loadConfigFromPath falls back to parseConfigPartially() which
validates each top-level key in isolation, keeps the sections that
pass, and logs which sections were skipped.

Closes code-yeongyu#1767
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Cannot be 100% sure of no regressions. The new parseConfigPartially function has complex logic with Zod schema validation that could have edge cases. The tests cover basic scenarios but 189 lines of变化

@singbong
Copy link

Closing as user requested.

1 similar comment
@singbong
Copy link

Closing as user requested.

@kaizen403
Copy link
Contributor Author

@code-yeongyu can you take a look at this fix?

@code-yeongyu code-yeongyu self-assigned this Feb 12, 2026
Sign up for free to 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.

[Bug]: Single invalid config field silently discards entire oh-my-opencode.json (underlying cause of #919 not fixed)

3 participants