{"record":{"id":"b83c09aa1b845337","repo":"alibaba/open-code-review","slug":"resolve-llm-endpoint-w","errorCode":null,"errorMessage":"resolve LLM endpoint: %w","messagePattern":"resolve LLM endpoint: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/llm_cmd.go","lineNumber":66,"sourceCode":"func init() {\n\tllmCmd.AddCommand(llmTestCmd)\n\tllmCmd.AddCommand(llmProvidersCmd)\n}\n\nfunc runLLMTest() error {\n\tcfgPath, err := resolveConfigPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tappCfg, err := LoadAppConfig(cfgPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load config: %w\", err)\n\t}\n\n\tep, err := llm.ResolveEndpoint(cfgPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve LLM endpoint: %w\", err)\n\t}\n\n\ttask, err := testconnection.LoadDefault()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load test task config: %w\", err)\n\t}\n\tvar lang string\n\tif appCfg != nil {\n\t\tlang = appCfg.Language\n\t}\n\ttask.ApplyLanguage(lang)\n\n\ttimeout := 30 * time.Second\n\tif task.Timeout > 0 {\n\t\ttimeout = time.Duration(task.Timeout) * time.Second\n\t}\n\n\t// No retry collector: llm test is a connectivity probe, not a review, and the","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/llm_cmd.go#L48-L84","documentation":"This error wraps a failure from llm.ResolveEndpoint during `ocr llm test`. Endpoint resolution combines the config file, environment variables, and provider presets to decide which LLM URL/model/credentials to use; if no usable endpoint can be derived, this error surfaces with the underlying cause wrapped via %w.","triggerScenarios":"Running `ocr llm test` when llm.ResolveEndpoint(cfgPath) fails: no provider or manual URL configured, required API-key env vars missing, or an unsupported/unknown provider value in the config.","commonSituations":"Fresh install with no config filled in; missing OPENAI_API_KEY / ANTHROPIC_API_KEY style env vars; typo'd provider name in config; config sets Bedrock but AWS credentials/region are absent.","solutions":["Configure an LLM provider via `ocr config provider` and confirm the URL/model are saved.","Export the required API-key environment variable for your chosen provider.","Check the wrapped cause after 'resolve LLM endpoint:' — it states what could not be resolved (provider, URL, or credentials).","If using Bedrock, set AWS_REGION and valid AWS credentials."],"exampleFix":"// before: config has no endpoint\n[llm]\nmodel = \"gpt-4o\"\n// after\n[llm]\nurl = \"https://api.openai.com/v1\"\nmodel = \"gpt-4o\"","handlingStrategy":"validation","validationCode":"// before running llm test, ensure an endpoint can be resolved\nif _, err := llm.ResolveEndpoint(cfgPath); err != nil {\n    fmt.Println(\"LLM endpoint not configured:\", err)\n    os.Exit(1)\n}","typeGuard":null,"tryCatchPattern":"ep, err := llm.ResolveEndpoint(cfgPath)\nif err != nil {\n    return fmt.Errorf(\"resolve LLM endpoint: %w — run 'ocr config provider' to configure\", err)\n}","preventionTips":["Run `ocr config provider` right after install to set a provider before any LLM command.","Keep required API-key env vars defined in shell profiles and CI secrets.","Verify provider name spelling against `ocr llm providers` output."],"tags":["config","llm","cli","environment"],"backgroundTag":"llm-endpoint-not-configured","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}