{"record":{"id":"e6643e0f315050d1","repo":"alibaba/open-code-review","slug":"config-not-loaded","errorCode":null,"errorMessage":"config not loaded","messagePattern":"config not loaded","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_tui.go","lineNumber":1340,"sourceCode":"\tout := make(map[string]ProviderEntry, len(src))\n\tfor k, v := range src {\n\t\tout[k] = cloneProviderEntry(v)\n\t}\n\treturn out\n}\n\nfunc cloneCustomProviderList(src []customProviderListItem) []customProviderListItem {\n\tout := make([]customProviderListItem, len(src))\n\tfor i, cp := range src {\n\t\tout[i] = customProviderListItem{name: cp.name, entry: cloneProviderEntry(cp.entry)}\n\t}\n\treturn out\n}\n\nfunc (m *providerTUIModel) applyEditCustomProviderSave() error {\n\tif m.existingCfg == nil {\n\t\tm.formError = \"failed to save: config not loaded\"\n\t\treturn fmt.Errorf(\"config not loaded\")\n\t}\n\tif m.configPath == \"\" {\n\t\tm.formError = \"failed to save: config path not available\"\n\t\treturn fmt.Errorf(\"config path not available\")\n\t}\n\tr := m.result()\n\tbackupProviders := cloneCustomProvidersMap(m.existingCfg.CustomProviders)\n\tbackupActiveProvider := m.existingCfg.Provider\n\tbackupActiveModel := m.existingCfg.Model\n\tbackupCustomList := cloneCustomProviderList(m.customProviders)\n\n\tif m.existingCfg.CustomProviders == nil {\n\t\tm.existingCfg.CustomProviders = make(map[string]ProviderEntry)\n\t}\n\tentry := m.existingCfg.CustomProviders[r.editTargetName]\n\tif r.model != \"\" {\n\t\tentry.Model = r.model\n\t}","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_tui.go#L1322-L1358","documentation":"applyEditCustomProviderSave is called before any config was loaded into the TUI model (m.existingCfg is nil), so there is nothing to mutate or save. Normally the model loads config at startup; this sentinel means the edit/save flow ran without that initialization. The message is also mirrored to m.formError as 'failed to save: config not loaded'.","triggerScenarios":"Thrown at cmd/opencodereview/provider_tui.go:1340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Load a config first (open the provider TUI through the normal flow so the config is loaded before editing)","Do not call applyEditCustomProviderSave before config initialization; re-enter the TUI to reload state","Check that the TUI's init path ran loadOrCreateConfig successfully before attempting a save"],"exampleFix":null,"handlingStrategy":"type-guard","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-08T15:18:49.778Z"}