invalid config structure - OpenCode
Quick fix
Fix the update order: save the database row only after the OpenCode live configuration is written successfully; keep the original record if writing fails.
Symptom
Section titled “Symptom”invalid config structureThe normal add-style update branch for an OpenCode provider saves the database row before calling the live configuration writer. If the writer returns an error because the configuration fragment structure is invalid, the live file remains unchanged, but the database retains the edited name and invalid `settings_config`.
Adjust OpenCode's normal update path: restore the previously saved provider row when live configuration writing fails, or persist the row only after the live write succeeds. The proposed local approach is to connect the write result to the existing `keep_row_if_written` helper.
Add a regression test: import an existing OpenCode provider, edit its name, and set `settings_config` to `{"models": []}`; confirm that when the update returns `invalid config structure`, both the live file and the provider in the database remain in their pre-update state.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 1 real issues
- Would a narrow OpenCode rollback fix with focused regression tests be welcome?
- The report proposes handling rollback only after a failed normal OpenCode update write, and notes that the local candidate approach does not change DB-only updates or separate OMO paths; the issue remains open and has no maintainer confirmation.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.