fix: parse config sections independently so one invalid field doesn't discard entire config #1771
+176
−13
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.