alibaba/open-code-review · warning
model name must not be empty
Error message
model name must not be empty
What it means
providerTUIModel.persistCustomModelName appends a model name to the active provider's Models list and saves the config; it rejects an empty name up front with this error. It prevents creating empty entries in the provider's model list in the config file.
Source
Thrown at cmd/opencodereview/provider_tui.go:816
m.refreshModelSelectionForCustom()
return m, nil
default:
var cmd tea.Cmd
m.modelInput, cmd = m.modelInput.Update(msg)
m.formError = ""
return m, cmd
}
}
// persistCustomModelName appends a single model name to the active provider's
// Models list (official or custom) and saves the config. It does not change
// the active model — the user picks that explicitly from the list afterwards.
//
// Returns (persisted, error). When no provider is active (neither official
// nor custom), persisted is false and the caller decides how to handle it.
func (m *providerTUIModel) persistCustomModelName(name string) (bool, error) {
if name == "" {
return false, fmt.Errorf("model name must not be empty")
}
if m.existingCfg == nil {
return false, nil
}
switch m.activeTab {
case tabCustom:
cp, ok := m.selectedCustomProvider()
if !ok {
return false, nil
}
entry := m.customProviderEntry(cp.name, cp.entry)
prevEntry := cloneProviderEntry(entry)
entry.Models = append(entry.Models, name)
if m.existingCfg.CustomProviders == nil {
m.existingCfg.CustomProviders = make(map[string]ProviderEntry)
}
m.existingCfg.CustomProviders[cp.name] = entry
cp.entry = entryView on GitHub (pinned to 5cf97d0d15)
Solutions
- Type a non-empty model name before confirming in the add-model input
- Ignore/handle the (false, error) return for blank input instead of surfacing it as a hard failure — this is a normal no-op case for blank input
- Trim whitespace in the caller and skip saving when the result is empty
Example fix
// before: caller surfaces blank-input error
persisted, err := m.persistCustomModelName(input)
if err != nil { m.err = err }
// after: skip blank input
if strings.TrimSpace(input) == "" { return }
persisted, err := m.persistCustomModelName(strings.TrimSpace(input)) Defensive patterns
Strategy: validation
Validate before calling
name := strings.TrimSpace(input)
if name == "" { return } // skip blank add-model input before persisting Type guard
func isNonEmptyModelName(s string) bool { return strings.TrimSpace(s) != "" } Try / catch
persisted, err := m.persistCustomModelName(name)
if err != nil {
if strings.Contains(err.Error(), "model name must not be empty") {
return false, nil // benign blank-input case, don't surface as failure
}
return persisted, err
} Prevention
- Disable the confirm action when the add-model input is empty
- Trim whitespace from input before persisting
- Treat blank input as a no-op rather than an error in UI flows
When it happens
Trigger: Calling persistCustomModelName with name == "" — e.g. the TUI's add-model input confirmed with no text typed, or a caller passing an empty string programmatically.
Common situations: Pressing Enter on an empty add-model prompt in the provider TUI; whitespace-only input trimmed to empty; automation driving the TUI state with a blank name.
Related errors
- URL is required for manual configuration
- model is required for manual configuration
- background file %q is a directory, not a file
- background file %q is %d bytes, exceeding the maximum of %d
- invalid max_tokens %q: must be a positive integer
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/f18299ef48e86176.
Report an issue: GitHub.