{"record":{"id":"1c7a890bbbe81d26","repo":"alibaba/open-code-review","slug":"config-not-available","errorCode":null,"errorMessage":"config not available","messagePattern":"config not available","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_tui.go","lineNumber":2818,"sourceCode":"\t\t\tm.modelIdx = i\n\t\t\treturn\n\t\t}\n\t}\n\tif len(models) > 0 {\n\t\tm.modelIdx = len(models) - 1\n\t} else {\n\t\tm.modelIdx = 0\n\t}\n}\n\n// persistAddedModelName appends a model to the provider's Models list in config\n// and saves to disk. It does not change the active model.\nfunc (m *modelTUIModel) persistAddedModelName(name string) error {\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"model name must not be empty\")\n\t}\n\tif m.existingCfg == nil || m.providerName == \"\" {\n\t\treturn fmt.Errorf(\"config not available\")\n\t}\n\tif m.isCustomProvider {\n\t\tif m.existingCfg.CustomProviders == nil {\n\t\t\tm.existingCfg.CustomProviders = make(map[string]ProviderEntry)\n\t\t}\n\t\tentry := m.existingCfg.CustomProviders[m.providerName]\n\t\tprevEntry := cloneProviderEntry(entry)\n\t\tentry.Models = ensureModelInList(entry.Models, name)\n\t\tm.existingCfg.CustomProviders[m.providerName] = entry\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[m.providerName] = prevEntry\n\t\t\t\t\tm.models = append([]string(nil), prevEntry.Models...)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"failed to save models: %w\", err)\n\t\t\t}\n\t\t}","sourceCodeStart":2800,"sourceCodeEnd":2836,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_tui.go#L2800-L2836","documentation":"persistAddedModelName was called without a loaded config (m.existingCfg is nil) or without a target provider name (m.providerName empty), so there is nowhere to append the model. This sentinel guards the model-add flow in the model TUI from writing to an uninitialized model state.","triggerScenarios":"Thrown at cmd/opencodereview/provider_tui.go:2818 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not add models before the TUI has loaded a config; re-enter the model TUI via the normal flow","Ensure a provider is selected (providerName must be set) before invoking model add","Check that the config initialization step succeeded — this guard fires when existingCfg is nil or providerName is empty"],"exampleFix":null,"handlingStrategy":"validation","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"}