open-code-review icon indicating copy to clipboard operation
open-code-review copied to clipboard

fix(config): warn when `llm.*` settings are silently ignored due to active provider

Open lizhengfeng101 opened this issue 4 months ago • 1 comments

Description

When a provider is already configured (e.g. via ocr config provider), running ocr config set llm.url <URL> (or any other llm.* key) succeeds silently — but the value is never used at runtime.

This happens because the endpoint resolver (internal/llm/resolver.go:258) checks cfg.Provider first:

if cfg.Provider != "" {
    return tryProviderConfig(cfg, modelOverride) // ← provider wins
}
return tryLegacyLlmConfig(cfg, modelOverride)    // ← llm.* is only a fallback

Users who previously ran ocr config provider (which sets the provider field) and then try to override the URL via ocr config set llm.url will see the old provider URL used instead, with no indication that their setting was ignored.

Reported in #580 — user configured llm.url pointing to a custom endpoint but ocr llm test still hit the previously-configured dashscope URL.

Scope

  • File(s): cmd/opencodereview/config_cmd.go
  • Function/area: runConfigSet (line 68), runConfigUnset (line 96)
  • Secondary: no changes needed in internal/llm/resolver.go (resolver priority logic is correct by design)

Acceptance Criteria

  • [ ] When ocr config set llm.* is called while cfg.Provider is non-empty, print a stderr warning like:
    [ocr] WARNING: provider "dashscope" is active and takes precedence over llm.* settings.
    [ocr] Use 'ocr config set providers.dashscope.<field> <value>' to configure the active provider,
    [ocr] or run 'ocr config unset provider' to disable provider-based config.
    
  • [ ] Support ocr config unset provider — clears the provider (and model) fields so the resolver falls back to llm.* config
  • [ ] Add/update unit tests for both behaviors
  • [ ] Tests pass (make test)
  • [ ] Code check passes (make check)

Context

Discovered via #580. The resolver's priority order is intentional (provider > llm.* > env > shell rc), but the config CLI gives no feedback when a user writes to a lower-priority layer that will be shadowed. This is a UX gap, not a resolver bug.

lizhengfeng101 avatar Jul 29 '26 14:07 lizhengfeng101

I would like to take this up

amh1k avatar Jul 29 '26 14:07 amh1k