{"record":{"id":"5d823ec71e381841","repo":"alibaba/open-code-review","slug":"resolve-s-w","errorCode":null,"errorMessage":"resolve %s: %w","messagePattern":"resolve (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/llm/resolver.go","lineNumber":139,"sourceCode":"\t\t\treturn ResolvedEndpoint{}, fmt.Errorf(\"resolve OCR config file: provider %q is not configured in %s section because the config file does not exist\", opts.Provider, section)\n\t\t}\n\t\treturn finalizeResolvedEndpoint(\"OCR config file\", ep, env), nil\n\t}\n\n\tstrategies := []struct {\n\t\tname string\n\t\tfn   func() (ResolvedEndpoint, bool, error)\n\t}{\n\t\t{\"OCR config file\", func() (ResolvedEndpoint, bool, error) { return tryOCRConfig(configPath, opts) }},\n\t\t{\"OCR environment\", func() (ResolvedEndpoint, bool, error) { return tryOCREnv(opts.Model) }},\n\t\t{\"Claude Code environment\", func() (ResolvedEndpoint, bool, error) { return tryCCEnv(opts.Model) }},\n\t\t{\"Shell rc file\", func() (ResolvedEndpoint, bool, error) { return tryShellRC(opts.Model) }},\n\t}\n\n\tfor _, strategy := range strategies {\n\t\tep, ok, err := strategy.fn()\n\t\tif err != nil {\n\t\t\treturn ResolvedEndpoint{}, fmt.Errorf(\"resolve %s: %w\", strategy.name, err)\n\t\t}\n\t\t// An ambient-auth endpoint is complete without a URL or token: the\n\t\t// transport supplies both. Everything else still needs all three.\n\t\tcomplete := ep.Model != \"\" && (ep.AmbientAuth || (ep.URL != \"\" && ep.Token != \"\"))\n\t\tif ok && complete {\n\t\t\treturn finalizeResolvedEndpoint(strategy.name, ep, env), nil\n\t\t}\n\t}\n\n\treturn ResolvedEndpoint{}, fmt.Errorf(\"no valid LLM endpoint configured; one of OCR_LLM_URL/OCR_LLM_TOKEN/OCR_LLM_MODEL, ~/.opencodereview/config.json, or ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN/ANTHROPIC_MODEL must be set\")\n}\n\n// envOverrides holds the global OCR_LLM_* overrides that apply to whichever\n// strategy resolves the endpoint. Parsed once, up front — see the call site in\n// ResolveEndpointWithOptions for why the timing matters.\ntype envOverrides struct {\n\ttimeout    time.Duration\n\thasTimeout bool","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/llm/resolver.go#L121-L157","documentation":"When no explicit provider is set, ResolveEndpointWithOptions runs ordered strategies (OCR config file, OCR env vars, Claude Code env, Shell rc file, etc.). If a strategy's loader returns an error — as opposed to merely reporting not-ok — resolution aborts immediately with \"resolve <strategy name>: %w\". The strategy name in the message tells you which config source failed.","triggerScenarios":"Any strategy function (tryOCRConfig, tryOCREnv, tryCCEnv, tryShellRC, ...) returns a non-nil error during ResolveEndpointWithOptions — e.g. malformed JSON in the OCR config file or an rc file that fails to parse/execute.","commonSituations":"Broken ~/.opencodereview/config.json found while scanning sources; an rc file (e.g. ~/.zshrc hook) emitting an error during variable extraction; a config file written by a newer ocr version with an incompatible schema.","solutions":["Read the wrapped cause and the strategy name in the message to locate the failing source file","Fix or temporarily rename/move the offending config/rc file","Validate the file's JSON/schema before rerunning"],"exampleFix":"// before: ~/.opencodereview/config.json with trailing comma\n{\"providers\": {\"x\": {\"model\": \"m\",}}}\n// after\n{\"providers\": {\"x\": {\"model\": \"m\"}}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"ep, err := llm.ResolveEndpoint(path)\nif err != nil {\n    var name string\n    if strings.HasPrefix(err.Error(), \"resolve \") {\n        name = strings.SplitN(err.Error(), \":\", 2)[0]\n    }\n    return fmt.Errorf(\"endpoint resolution failed (%s): %w\", name, err)\n}","preventionTips":["Validate each config source file (OCR config, rc files) after editing","Test resolution early with a small program calling ResolveEndpoint before long runs","Keep rc-file hooks that ocr reads fast-failing and silent"],"tags":["config","resolution","file-io"],"backgroundTag":"config-file-parse-error","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}