{"record":{"id":"58b5cb44514e5594","repo":"alibaba/open-code-review","slug":"failed-to-save-models-w","errorCode":null,"errorMessage":"failed to save models: %w","messagePattern":"failed to save models: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_tui.go","lineNumber":843,"sourceCode":"\t\t\treturn false, nil\n\t\t}\n\t\tentry := m.customProviderEntry(cp.name, cp.entry)\n\t\tprevEntry := cloneProviderEntry(entry)\n\t\tentry.Models = append(entry.Models, name)\n\t\tif m.existingCfg.CustomProviders == nil {\n\t\t\tm.existingCfg.CustomProviders = make(map[string]ProviderEntry)\n\t\t}\n\t\tm.existingCfg.CustomProviders[cp.name] = entry\n\t\tcp.entry = entry\n\t\tm.customProviders[m.customIdx] = cp\n\t\tif m.configPath != \"\" {\n\t\t\tif err := saveConfig(m.configPath, m.existingCfg); err != nil {\n\t\t\t\tif !m.reloadConfigAfterSaveFailure() {\n\t\t\t\t\tm.existingCfg.CustomProviders[cp.name] = prevEntry\n\t\t\t\t\tcp.entry = prevEntry\n\t\t\t\t\tm.customProviders[m.customIdx] = cp\n\t\t\t\t}\n\t\t\t\treturn false, fmt.Errorf(\"failed to save models: %w\", err)\n\t\t\t}\n\t\t}\n\t\tm.savedInSession = true\n\t\treturn true, nil\n\tcase tabOfficial:\n\t\tprovider := m.currentProvider()\n\t\tif provider.Name == \"\" {\n\t\t\treturn false, nil\n\t\t}\n\t\tif m.existingCfg.Providers == nil {\n\t\t\tm.existingCfg.Providers = make(map[string]ProviderEntry)\n\t\t}\n\t\tentry := m.existingCfg.Providers[provider.Name]\n\t\tprevEntry := cloneProviderEntry(entry)\n\t\tentry.Models = append(entry.Models, name)\n\t\tm.existingCfg.Providers[provider.Name] = entry\n\t\t// Intentionally do not mutate m.providers[officialIdx].Models: that slice\n\t\t// is a read-only snapshot from the provider registry (llm.ListProviders).","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_tui.go#L825-L861","documentation":"In the custom-provider TUI, after appending a model to a custom provider, saveConfig fails to persist the updated config to disk. The model rolls back the in-memory entry to its previous state (prevEntry); if reloadConfigAfterSaveFailure also cannot restore by re-reading the file, this error propagates. It means the model was added in the UI but the config file could not be written (permissions, disk full, bad path).","triggerScenarios":"Thrown at cmd/opencodereview/provider_tui.go:843 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and file permissions on the config file's directory","Inspect the wrapped error for the actual write failure (permission denied, disk full, invalid path)","Retry the save after fixing the filesystem issue; the TUI rolls back the in-memory entry when the save fails"],"exampleFix":null,"handlingStrategy":"try-catch","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"}