alibaba/open-code-review · error
config not loaded
Error message
config not loaded
What it means
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'.
Source
Thrown at cmd/opencodereview/provider_tui.go:1340
out := make(map[string]ProviderEntry, len(src))
for k, v := range src {
out[k] = cloneProviderEntry(v)
}
return out
}
func cloneCustomProviderList(src []customProviderListItem) []customProviderListItem {
out := make([]customProviderListItem, len(src))
for i, cp := range src {
out[i] = customProviderListItem{name: cp.name, entry: cloneProviderEntry(cp.entry)}
}
return out
}
func (m *providerTUIModel) applyEditCustomProviderSave() error {
if m.existingCfg == nil {
m.formError = "failed to save: config not loaded"
return fmt.Errorf("config not loaded")
}
if m.configPath == "" {
m.formError = "failed to save: config path not available"
return fmt.Errorf("config path not available")
}
r := m.result()
backupProviders := cloneCustomProvidersMap(m.existingCfg.CustomProviders)
backupActiveProvider := m.existingCfg.Provider
backupActiveModel := m.existingCfg.Model
backupCustomList := cloneCustomProviderList(m.customProviders)
if m.existingCfg.CustomProviders == nil {
m.existingCfg.CustomProviders = make(map[string]ProviderEntry)
}
entry := m.existingCfg.CustomProviders[r.editTargetName]
if r.model != "" {
entry.Model = r.model
}View on GitHub (pinned to 5cf97d0d15)
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
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at cmd/opencodereview/provider_tui.go:1340 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/e6643e0f315050d1.
Report an issue: GitHub.