alibaba/open-code-review · error
no provider configured. Run 'ocr config provider' first
Error message
no provider configured. Run 'ocr config provider' first
What it means
The model configuration command can only show models for a provider that is already configured. If the loaded config has an empty Provider field, runConfigModel aborts, instructing the user to configure a provider first with 'ocr config provider'.
Source
Thrown at cmd/opencodereview/provider_cmd.go:329
}
fmt.Println("\nTip: run 'ocr config model' to switch model later.")
return nil
}
func runConfigModel() error {
configPath, err := defaultConfigPath()
if err != nil {
return err
}
cfg, err := loadOrCreateConfig(configPath)
if err != nil {
return fmt.Errorf("load config: %w", err)
}
if cfg.Provider == "" {
return fmt.Errorf("no provider configured. Run 'ocr config provider' first")
}
currentModel := ""
provider := llm.Provider{Name: cfg.Provider, DisplayName: cfg.Provider}
isCustom := false
registryModels := []string(nil)
if preset, isPreset := llm.LookupProvider(cfg.Provider); isPreset {
provider = preset
registryModels = append([]string(nil), preset.Models...)
if entry, ok := cfg.Providers[cfg.Provider]; ok {
currentModel = activeModelForProvider(cfg, cfg.Provider, entry)
provider.Models = mergeModelLists(provider.Models, entry.Models)
// Surface the effective Base URL: a configured override takes
// precedence over the preset default so users can confirm their
// gateway is in use from the model picker.
if entry.URL != "" {
provider.BaseURL = entry.URL
}View on GitHub (pinned to 5cf97d0d15)
Solutions
- Run 'ocr config provider' to select a provider, then rerun 'ocr config model'
- Verify the intended config file is being used (check config path flag/env)
- Set provider manually in the config file if scripting setup
Example fix
// before (config.toml) # provider not set // after provider = "openai" model = "gpt-4o"
Defensive patterns
Strategy: validation
Validate before calling
cfg, _ := loadOrCreateConfig(configPath)
if cfg.Provider == "" {
// run 'ocr config provider' first
} Try / catch
if err := runConfigModel(path); err != nil && strings.Contains(err.Error(), "no provider configured") {
// chain: run provider config, then model config
} Prevention
- Complete 'ocr config provider' before 'ocr config model' on new machines
- Bootstrap configs with provider already set when scripting setup
- Confirm which config file is in use before editing
When it happens
Trigger: 'ocr config model' runs against a config file where cfg.Provider == "" — a fresh/empty config, or one created without completing the provider step.
Common situations: First run of ocr where only 'config model' was invoked; config file truncated or provider key removed by hand; running with a different OCR_CONFIG_PATH that points to an empty file.
Related errors
- custom provider %q not found
- provider %q is not configured; set a core field first (proto
- provider name is required
- model is required
- provider and model are required
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/14afb8aa010e2dfe.
Report an issue: GitHub.