alibaba/open-code-review · error
save config: %w
Error message
save config: %w
What it means
saveConfig failed while persisting an edited custom provider (permissions, path, disk, or serialization). The handler first tries to reload the config from disk to resync in-memory state; if the reload also fails it restores the pre-save backup (backupProviders/backupActiveProvider/backup Model) and surfaces the save error, which is wrapped here with 'save config:'. The edit is lost; the file is left as it was.
Source
Thrown at cmd/opencodereview/provider_tui.go:1402
if m.existingCfg.Provider == r.editTargetName {
m.existingCfg.Provider = r.provider
m.existingCfg.Model = ""
}
}
m.existingCfg.CustomProviders[r.provider] = entry
if err := saveConfig(m.configPath, m.existingCfg); err != nil {
m.formError = fmt.Sprintf("failed to save: %v", err)
if reloaded, reloadErr := loadOrCreateConfig(m.configPath); reloadErr == nil {
m.existingCfg = reloaded
m.customProviders = collectCustomProviders(reloaded)
} else {
m.existingCfg.CustomProviders = backupProviders
m.existingCfg.Provider = backupActiveProvider
m.existingCfg.Model = backupActiveModel
m.customProviders = backupCustomList
}
return fmt.Errorf("save config: %w", err)
}
m.customProviders = collectCustomProviders(m.existingCfg)
if idx := m.findCustomIdx(r.provider); idx >= 0 {
m.customIdx = idx
}
m.savedInSession = true
return nil
}
func (m providerTUIModel) findCustomIdx(name string) int {
for i, cp := range m.customProviders {
if cp.name == name {
return i
}
}
return -1
}
View on GitHub (pinned to 5cf97d0d15)
Solutions
- Inspect the wrapped error to determine why the config write failed (permissions, disk space, malformed path)
- Fix the filesystem issue and retry the save from the TUI
- On failure the code attempts to reload the config from disk, or restores the backup of provider/model state if reload also fails; restart the TUI if state seems inconsistent
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at cmd/opencodereview/provider_tui.go:1402 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/da456f9b096f8ee9.
Report an issue: GitHub.