alibaba/open-code-review · error
provider name is required
Error message
provider name is required
What it means
applyCustomProviderConfig is the step of 'ocr config provider' that persists a custom (non-preset) provider entry chosen in the TUI wizard. It rejects the write when the wizard result carries no provider name, since a config entry cannot be keyed without one. The check guards result.provider, which the TUI flow is expected to populate.
Source
Thrown at cmd/opencodereview/provider_cmd.go:159
fmt.Println("\nManual configuration saved.")
fmt.Printf("URL: %s\n", result.url)
fmt.Printf("Protocol: %s\n", protocol)
fmt.Printf("Model: %s\n", result.model)
fmt.Println("\nTesting connection...")
if err := runLLMTest(); err != nil {
fmt.Fprintf(os.Stderr, "Connection test failed: %v\n", err)
fmt.Fprintln(os.Stderr, "Configuration has been saved. Fix the issue and run 'ocr llm test' to re-verify.")
return nil
}
return nil
}
func applyCustomProviderConfig(configPath string, cfg *Config, result providerTUIResult) error {
if result.provider == "" {
return fmt.Errorf("provider name is required")
}
model := result.resolvedModel()
if model == "" {
return fmt.Errorf("model is required")
}
if cfg.CustomProviders == nil {
cfg.CustomProviders = make(map[string]ProviderEntry)
}
entry := cfg.CustomProviders[result.provider]
entry.Model = model
if len(result.models) > 0 {
entry.Models = append([]string(nil), result.models...)
}
entry.Models = ensureModelInList(entry.Models, model)
if result.url != "" {
entry.URL = result.urlView on GitHub (pinned to 5cf97d0d15)
Solutions
- Set the provider name in the TUI result (result.provider) before calling applyCustomProviderConfig
- Ensure the provider wizard completes selection rather than returning early on cancel; exit the command cleanly instead
- If constructing providerTUIResult programmatically, pass the provider name explicitly
Example fix
// before
result := providerTUIResult{} // provider empty
err := applyCustomProviderConfig(path, cfg, result)
// after
result := providerTUIResult{provider: "my-llm", model: "model-a"}
err := applyCustomProviderConfig(path, cfg, result) Defensive patterns
Strategy: validation
Validate before calling
if result.provider == "" {
return errors.New("select a provider before saving configuration")
}
// safe to call applyCustomProviderConfig(configPath, cfg, result) Type guard
func hasProvider(r providerTUIResult) bool { return r.provider != "" } Prevention
- Always complete the wizard selection; on cancel, exit the command instead of applying
- Assert provider non-empty in tests that exercise the apply path
- Treat providerTUIResult.provider as a required field when constructing it programmatically
When it happens
Trigger: Running the provider config flow where providerTUIResult.provider is the empty string when applyCustomProviderConfig is invoked (e.g. the TUI was skipped, cancelled, or produced an empty selection); exercised by TestApplyCustomProviderConfig_MissingProvider.
Common situations: Cancelling out of the provider wizard so the selection struct stays zero-valued; a scripted/non-interactive path constructing providerTUIResult manually and forgetting to set Provider; refactors that reorder wizard fields so the provider pick is lost.
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
- model is required
- provider and model are required
- custom provider %q not found
- invalid max_tokens %q: must be a positive integer
- unknown config key: %s Supported keys: %s Provider fields: a
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/cfeccca14fedf161.
Report an issue: GitHub.