alibaba/open-code-review · error
resolve %s: %w
Error message
resolve %s: %w
What it means
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.
Source
Thrown at internal/llm/resolver.go:139
return 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)
}
return finalizeResolvedEndpoint("OCR config file", ep, env), nil
}
strategies := []struct {
name string
fn func() (ResolvedEndpoint, bool, error)
}{
{"OCR config file", func() (ResolvedEndpoint, bool, error) { return tryOCRConfig(configPath, opts) }},
{"OCR environment", func() (ResolvedEndpoint, bool, error) { return tryOCREnv(opts.Model) }},
{"Claude Code environment", func() (ResolvedEndpoint, bool, error) { return tryCCEnv(opts.Model) }},
{"Shell rc file", func() (ResolvedEndpoint, bool, error) { return tryShellRC(opts.Model) }},
}
for _, strategy := range strategies {
ep, ok, err := strategy.fn()
if err != nil {
return ResolvedEndpoint{}, fmt.Errorf("resolve %s: %w", strategy.name, err)
}
// An ambient-auth endpoint is complete without a URL or token: the
// transport supplies both. Everything else still needs all three.
complete := ep.Model != "" && (ep.AmbientAuth || (ep.URL != "" && ep.Token != ""))
if ok && complete {
return finalizeResolvedEndpoint(strategy.name, ep, env), nil
}
}
return 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")
}
// envOverrides holds the global OCR_LLM_* overrides that apply to whichever
// strategy resolves the endpoint. Parsed once, up front — see the call site in
// ResolveEndpointWithOptions for why the timing matters.
type envOverrides struct {
timeout time.Duration
hasTimeout boolView on GitHub (pinned to 5cf97d0d15)
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
Example fix
// before: ~/.opencodereview/config.json with trailing comma
{"providers": {"x": {"model": "m",}}}
// after
{"providers": {"x": {"model": "m"}}} Defensive patterns
Strategy: try-catch
Try / catch
ep, err := llm.ResolveEndpoint(path)
if err != nil {
var name string
if strings.HasPrefix(err.Error(), "resolve ") {
name = strings.SplitN(err.Error(), ":", 2)[0]
}
return fmt.Errorf("endpoint resolution failed (%s): %w", name, err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- resolve OCR config file: %w
- read app config %s: %w
- read tools file %s: %w
- resolve OCR config file: provider %q is not configured in %s
- no valid LLM endpoint configured; one of OCR_LLM_URL/OCR_LLM
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/5d823ec71e381841.
Report an issue: GitHub.