{"record":{"id":"14afb8aa010e2dfe","repo":"alibaba/open-code-review","slug":"no-provider-configured-run-ocr-config-provider","errorCode":null,"errorMessage":"no provider configured. Run 'ocr config provider' first","messagePattern":"no provider configured\\. Run 'ocr config provider' first","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_cmd.go","lineNumber":329,"sourceCode":"\t}\n\n\tfmt.Println(\"\\nTip: run 'ocr config model' to switch model later.\")\n\treturn nil\n}\n\nfunc runConfigModel() error {\n\tconfigPath, err := defaultConfigPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfg, err := loadOrCreateConfig(configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load config: %w\", err)\n\t}\n\n\tif cfg.Provider == \"\" {\n\t\treturn fmt.Errorf(\"no provider configured. Run 'ocr config provider' first\")\n\t}\n\n\tcurrentModel := \"\"\n\tprovider := llm.Provider{Name: cfg.Provider, DisplayName: cfg.Provider}\n\tisCustom := false\n\tregistryModels := []string(nil)\n\tif preset, isPreset := llm.LookupProvider(cfg.Provider); isPreset {\n\t\tprovider = preset\n\t\tregistryModels = append([]string(nil), preset.Models...)\n\t\tif entry, ok := cfg.Providers[cfg.Provider]; ok {\n\t\t\tcurrentModel = activeModelForProvider(cfg, cfg.Provider, entry)\n\t\t\tprovider.Models = mergeModelLists(provider.Models, entry.Models)\n\t\t\t// Surface the effective Base URL: a configured override takes\n\t\t\t// precedence over the preset default so users can confirm their\n\t\t\t// gateway is in use from the model picker.\n\t\t\tif entry.URL != \"\" {\n\t\t\t\tprovider.BaseURL = entry.URL\n\t\t\t}","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_cmd.go#L311-L347","documentation":"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'.","triggerScenarios":"'ocr config model' runs against a config file where cfg.Provider == \"\" — a fresh/empty config, or one created without completing the provider step.","commonSituations":"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.","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"],"exampleFix":"// before (config.toml)\n# provider not set\n// after\nprovider = \"openai\"\nmodel = \"gpt-4o\"","handlingStrategy":"validation","validationCode":"cfg, _ := loadOrCreateConfig(configPath)\nif cfg.Provider == \"\" {\n    // run 'ocr config provider' first\n}","typeGuard":null,"tryCatchPattern":"if err := runConfigModel(path); err != nil && strings.Contains(err.Error(), \"no provider configured\") {\n    // chain: run provider config, then model config\n}","preventionTips":["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"],"tags":["config","cli","prerequisite","provider"],"backgroundTag":"missing-prerequisite-configuration","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}