alibaba/open-code-review · error
config not available
Error message
config not available
What it means
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.
Source
Thrown at cmd/opencodereview/provider_tui.go:2818
m.modelIdx = i
return
}
}
if len(models) > 0 {
m.modelIdx = len(models) - 1
} else {
m.modelIdx = 0
}
}
// persistAddedModelName appends a model to the provider's Models list in config
// and saves to disk. It does not change the active model.
func (m *modelTUIModel) persistAddedModelName(name string) error {
if name == "" {
return fmt.Errorf("model name must not be empty")
}
if m.existingCfg == nil || m.providerName == "" {
return fmt.Errorf("config not available")
}
if m.isCustomProvider {
if m.existingCfg.CustomProviders == nil {
m.existingCfg.CustomProviders = make(map[string]ProviderEntry)
}
entry := m.existingCfg.CustomProviders[m.providerName]
prevEntry := cloneProviderEntry(entry)
entry.Models = ensureModelInList(entry.Models, name)
m.existingCfg.CustomProviders[m.providerName] = entry
if m.configPath != "" {
if err := saveConfig(m.configPath, m.existingCfg); err != nil {
if !m.reloadConfigAfterSaveFailure() {
m.existingCfg.CustomProviders[m.providerName] = prevEntry
m.models = append([]string(nil), prevEntry.Models...)
}
return fmt.Errorf("failed to save models: %w", err)
}
}View on GitHub (pinned to 5cf97d0d15)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/opencodereview/provider_tui.go:2818 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/1c7a890bbbe81d26.
Report an issue: GitHub.