{"record":{"id":"da456f9b096f8ee9","repo":"alibaba/open-code-review","slug":"save-config-w","errorCode":null,"errorMessage":"save config: %w","messagePattern":"save config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_tui.go","lineNumber":1402,"sourceCode":"\t\tif m.existingCfg.Provider == r.editTargetName {\n\t\t\tm.existingCfg.Provider = r.provider\n\t\t\tm.existingCfg.Model = \"\"\n\t\t}\n\t}\n\tm.existingCfg.CustomProviders[r.provider] = entry\n\n\tif err := saveConfig(m.configPath, m.existingCfg); err != nil {\n\t\tm.formError = fmt.Sprintf(\"failed to save: %v\", err)\n\t\tif reloaded, reloadErr := loadOrCreateConfig(m.configPath); reloadErr == nil {\n\t\t\tm.existingCfg = reloaded\n\t\t\tm.customProviders = collectCustomProviders(reloaded)\n\t\t} else {\n\t\t\tm.existingCfg.CustomProviders = backupProviders\n\t\t\tm.existingCfg.Provider = backupActiveProvider\n\t\t\tm.existingCfg.Model = backupActiveModel\n\t\t\tm.customProviders = backupCustomList\n\t\t}\n\t\treturn fmt.Errorf(\"save config: %w\", err)\n\t}\n\tm.customProviders = collectCustomProviders(m.existingCfg)\n\tif idx := m.findCustomIdx(r.provider); idx >= 0 {\n\t\tm.customIdx = idx\n\t}\n\tm.savedInSession = true\n\treturn nil\n}\n\nfunc (m providerTUIModel) findCustomIdx(name string) int {\n\tfor i, cp := range m.customProviders {\n\t\tif cp.name == name {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n","sourceCodeStart":1384,"sourceCodeEnd":1420,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_tui.go#L1384-L1420","documentation":"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.","triggerScenarios":"Thrown at cmd/opencodereview/provider_tui.go:1402 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}