{"record":{"id":"3cedb288c8fc3568","repo":"alibaba/open-code-review","slug":"resolve-llm-endpoint-w-3cedb2","errorCode":null,"errorMessage":"resolve LLM endpoint: %w","messagePattern":"resolve LLM endpoint: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared.go","lineNumber":239,"sourceCode":"\tcfgPath, err := defaultConfigPath()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tappCfg, err := LoadAppConfig(cfgPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load app config: %w\", err)\n\t}\n\t// Apply the language directive even when the config file is missing\n\t// (upstream #fix: ApplyLanguage with empty lang falls back to default).\n\tvar lang string\n\tif appCfg != nil {\n\t\tlang = appCfg.Language\n\t}\n\ttpl.ApplyLanguage(lang)\n\n\tep, err := llm.ResolveEndpointWithOptions(cfgPath, resolveOpts)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolve LLM endpoint: %w\", err)\n\t}\n\n\tretryCollector := newRetryCollector()\n\n\treturn &llmRuntime{\n\t\tClient:         llm.NewLLMClient(ep, retryCollector),\n\t\tModel:          ep.Model,\n\t\tProvider:       ep.Provider,\n\t\tPlanToolDefs:   planToolDefs,\n\t\tMainToolDefs:   mainToolDefs,\n\t\tCollector:      tool.NewCommentCollector(),\n\t\tRetryCollector: retryCollector,\n\t\tAppCfg:         appCfg,\n\t\tRuntimeConfig: agent.RuntimeConfig{\n\t\t\tProtocol:     ep.Protocol,\n\t\t\tEndpointHost: sanitizeEndpointHost(ep.URL),\n\t\t\tLanguage:     lang,\n\t\t\tTimeout:      ep.Timeout,","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared.go#L221-L257","documentation":"loadLLMRuntime resolves the LLM endpoint via llm.ResolveEndpointWithOptions and wraps failure as `resolve LLM endpoint: %w`. Resolution combines the config file, environment, and CLI resolve options; it fails when no usable endpoint is configured (missing URL/api key, invalid provider, or conflicting options).","triggerScenarios":"ocr review/scan invoked with no endpoint in config and no env/flags supplying one; an explicit resolveOpts that references an unknown provider; malformed endpoint URL; missing required credentials for the chosen provider.","commonSituations":"Fresh install without running any setup; CI job missing the API-key env var; renamed env variables after a version upgrade; custom self-hosted endpoint URL with a typo; switching providers without updating credentials.","solutions":["Configure the LLM endpoint (URL + API key) in the config file or export the expected env variables","If using flags/options, verify the provider name and URL are valid for your ocr version","Check for typos in the endpoint URL (scheme, host, port)","Confirm CI secrets are actually set in the job environment"],"exampleFix":"// before\nexport OPENAI_BASE_URL=api.openai.com/v1   # missing scheme\n// after\nexport OPENAI_BASE_URL=https://api.openai.com/v1\nexport OPENAI_API_KEY=sk-...","handlingStrategy":"validation","validationCode":"cfg, _ := LoadAppConfig(cfgPath)\nif cfg == nil || cfg.Endpoint == \"\" && os.Getenv(\"OCR_LLM_URL\") == \"\" {\n\treturn errors.New(\"no LLM endpoint configured: set it in config or env before running\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif strings.Contains(err.Error(), \"resolve LLM endpoint\") {\n\t\t// prompt user to run setup or export credentials, don't retry blindly\n\t}\n\treturn err\n}","preventionTips":["Run initial setup before first use and commit a sanitized config template","Verify API-key env vars exist in CI (env | grep -i key)","URL-encode and scheme-check custom endpoint URLs"],"tags":["go","llm","configuration"],"backgroundTag":"missing-llm-endpoint-config","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}