alibaba/open-code-review · error

unsupported tab for custom model: %v

Error message

unsupported tab for custom model: %v

What it means

Guard in the provider TUI's model-add flow: the save routine was invoked from a tab whose context is not a recognized custom-model context. The tab value (e.g. official provider list, an edit form, search) cannot have models added to it, so the function refuses rather than writing a model to the wrong provider entry.

Source

Thrown at cmd/opencodereview/provider_tui.go:875

		prevEntry := cloneProviderEntry(entry)
		entry.Models = append(entry.Models, name)
		m.existingCfg.Providers[provider.Name] = entry
		// Intentionally do not mutate m.providers[officialIdx].Models: that slice
		// is a read-only snapshot from the provider registry (llm.ListProviders).
		// User-added models live only in existingCfg.Providers; models() merges both
		// at display time, unlike custom tab where customProviders is the sole list.
		if m.configPath != "" {
			if err := saveConfig(m.configPath, m.existingCfg); err != nil {
				if !m.reloadConfigAfterSaveFailure() {
					m.existingCfg.Providers[provider.Name] = prevEntry
				}
				return false, fmt.Errorf("failed to save models: %w", err)
			}
		}
		m.savedInSession = true
		return true, nil
	default:
		return false, fmt.Errorf("unsupported tab for custom model: %v", m.activeTab)
	}
}

const maskedSecretDisplayLen = 20

func maskedSecretPlaceholder() string {
	return strings.Repeat("*", maskedSecretDisplayLen)
}

// isUserEditMsg reports whether msg represents user text input (typing or paste).
func isUserEditMsg(msg tea.Msg) bool {
	switch msg.(type) {
	case tea.KeyPressMsg, tea.PasteMsg:
		return true
	default:
		return false
	}
}

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Report this as a bug: this message indicates an internal state error where the add-model flow was invoked from an unexpected tab
  2. Avoid manually constructing model-add requests for official providers through this path; user models for official providers belong in existingCfg.Providers only
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/opencodereview/provider_tui.go:875 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/40222ceed1ae61fe. Report an issue: GitHub.