fix: parse config sections independently so one invalid field doesn't discard entire config#1771
Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom Feb 13, 2026
Conversation
… 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
There was a problem hiding this comment.
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变化
|
Closing as user requested. |
1 similar comment
|
Closing as user requested. |
Contributor
Author
|
@code-yeongyu can you take a look at this fix? |
Contributor
Author
|
@code-yeongyu all good? |
Owner
|
Thank you for this fix! Having the entire config silently disappear because of one typo was a real pain point. The partial parsing approach is elegant — fast path for valid configs, graceful degradation for invalid ones, with clear logging of what was skipped. Great test coverage too. Much appreciated! 🙏 |
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 free
to 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.
fixes #1767
summary
a single invalid field in oh-my-opencode.json (e.g. wrong type for
prometheus.permission.edit) causedsafeParseto 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
loadConfigFromPathusedOhMyOpenCodeConfigSchema.safeParse()on the full raw config. if any field failed validation the function returnednull, and the caller fell back to{}.changes
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 failloadConfigFromPathnow falls back to partial parsing instead of returning null on validation failuretesting
bun test src/plugin-config.test.ts— 11 passbun run typecheck— cleanbun 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.
Written for commit d3978ab. Summary will update on new commits.