alibaba/open-code-review · error
resolve LLM endpoint: %w
Error message
resolve LLM endpoint: %w
What it means
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.
Source
Thrown at cmd/opencodereview/llm_cmd.go:66
func init() {
llmCmd.AddCommand(llmTestCmd)
llmCmd.AddCommand(llmProvidersCmd)
}
func runLLMTest() error {
cfgPath, err := resolveConfigPath()
if err != nil {
return err
}
appCfg, err := LoadAppConfig(cfgPath)
if err != nil {
return fmt.Errorf("load config: %w", err)
}
ep, err := llm.ResolveEndpoint(cfgPath)
if err != nil {
return fmt.Errorf("resolve LLM endpoint: %w", err)
}
task, err := testconnection.LoadDefault()
if err != nil {
return fmt.Errorf("load test task config: %w", err)
}
var lang string
if appCfg != nil {
lang = appCfg.Language
}
task.ApplyLanguage(lang)
timeout := 30 * time.Second
if task.Timeout > 0 {
timeout = time.Duration(task.Timeout) * time.Second
}
// No retry collector: llm test is a connectivity probe, not a review, and theView on GitHub (pinned to 5cf97d0d15)
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.
Example fix
// before: config has no endpoint [llm] model = "gpt-4o" // after [llm] url = "https://api.openai.com/v1" model = "gpt-4o"
Defensive patterns
Strategy: validation
Validate before calling
// before running llm test, ensure an endpoint can be resolved
if _, err := llm.ResolveEndpoint(cfgPath); err != nil {
fmt.Println("LLM endpoint not configured:", err)
os.Exit(1)
} Try / catch
ep, err := llm.ResolveEndpoint(cfgPath)
if err != nil {
return fmt.Errorf("resolve LLM endpoint: %w — run 'ocr config provider' to configure", err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- load test task config: %w
- cannot determine home directory: %w
- load config: %w
- unset supports provider, max_tokens, effort, custom_provider
- MCP server %q not found
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/b83c09aa1b845337.
Report an issue: GitHub.