alibaba/open-code-review · error
model is required for manual configuration
Error message
model is required for manual configuration
What it means
applyManualConfig requires a model name when saving a manually configured provider and refuses to persist a config without one. Manual mode writes cfg.Llm.Model directly with no provider defaults, so an empty model would leave the resolved endpoint without a usable model ID.
Source
Thrown at cmd/opencodereview/provider_cmd.go:108
for _, m := range toRemove {
removeSet[m] = struct{}{}
}
result := make([]string, 0, len(existing))
for _, m := range existing {
if _, found := removeSet[m]; found {
continue
}
result = append(result, m)
}
return result
}
func applyManualConfig(configPath string, cfg *Config, result providerTUIResult) error {
if result.url == "" {
return fmt.Errorf("URL is required for manual configuration")
}
if result.model == "" {
return fmt.Errorf("model is required for manual configuration")
}
cfg.Provider = ""
cfg.Model = ""
cfg.Llm.URL = result.url
cfg.Llm.Model = result.model
cfg.Llm.AuthToken = result.apiKey
authHeader, err := llm.NormalizeAuthHeader(result.authHeader)
if err != nil {
return fmt.Errorf("invalid auth_header: %w", err)
}
cfg.Llm.AuthHeader = authHeader
// Write the canonical protocol so resolver picks it up directly. Also
// mirror use_anthropic so configs read correctly on older binaries that
// predate llm.protocol: anthropic -> true, the OpenAI family (including
// openai-responses, which has no exact boolean equivalent) -> false, so
// older binaries pick the OpenAI auth header/endpoint instead of wrongly
// defaulting to anthropic.View on GitHub (pinned to 5cf97d0d15)
Solutions
- Reopen `ocr config provider` and enter the model name (e.g. gpt-4o, claude-sonnet-4) in the manual form.
- Use the built-in provider selection instead of manual mode to get model defaults.
- In code/tests, set result.model before calling applyManualConfig.
Example fix
// before
result := providerTUIResult{url: "https://api.openai.com/v1"}
// after
result := providerTUIResult{url: "https://api.openai.com/v1", model: "gpt-4o"} Defensive patterns
Strategy: validation
Validate before calling
if result.model == "" {
return errors.New("model is required for manual configuration")
} Try / catch
if err := applyManualConfig(path, cfg, result); err != nil {
if strings.Contains(err.Error(), "model is required") {
// re-prompt for the model
}
} Prevention
- Confirm the model name against the provider's model list before saving.
- Enter both URL and model together when using manual configuration.
- Use the provider preset flow to get sensible model defaults.
When it happens
Trigger: Confirming the manual-configuration screen of `ocr config provider` with the model field left empty; calling applyManualConfig with a providerTUIResult whose model field is "" (URL already non-empty, so the URL check passed).
Common situations: Entering a URL but forgetting the model in the TUI; assuming the tool will infer the model from the URL; test fixtures setting only the url field.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- URL is required for manual configuration
- invalid max_tokens %q: must be a positive integer
- unknown config key: %s Supported keys: %s Provider fields: a
- invalid URL for %s: %w
- invalid model list for %s: %w
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/d418fd380f7f51d9.
Report an issue: GitHub.