fix(config): warn when active provider shadows llm settings
Description
Warns users when they configure llm.* settings while an active provider takes precedence over them.
Adds ocr config unset provider, which clears the active provider and top-level model so OCR can fall back to legacy llm.* configuration. Saved provider entries and credentials remain intact for later reuse.
Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Refactoring (no functional changes)
- [x] Documentation update
- [ ] CI / Build / Tooling
How Has This Been Tested?
-
[x]
make testpasses locally -
[x] Manual testing (describe below)
-
Ran focused configuration and resolver tests:
go test ./cmd/opencodereview ./internal/llm -
Ran the full race-enabled suite:
make test -
Ran formatting, dependency, and vet checks:
make check -
Added test coverage for warnings on shadowed
llm.*settings and forocr config unset provider.
Checklist
- [x] My code follows the project's coding style (
go fmt,go vet) - [x] I have performed a self-review of my code
- [x] I have added tests that prove my fix is effective or my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I have updated the documentation accordingly (if applicable)
- [x] I have signed the CLA
Related Issues
Closes #583
๐ OpenCodeReview found 2 issue(s) in this PR.
- โ Successfully posted inline: 1 comment(s)
- ๐ In summary (no line info): 1 comment(s)
[bug ยท medium]
๐ cmd/opencodereview/flags.go
โ ๏ธ GitHub could not post this as an inline comment: No line information provided
Bug: The warning always suggests providers.<name>.<field> even when the active provider is a custom provider. For custom providers, the correct config path is custom_providers.<name>.<field>. You should use llm.LookupProvider(provider) (already used elsewhere in this file) to determine whether the provider is built-in or custom, and adjust the suggested prefix accordingly.
๐ก Suggested Change
Before:
return fmt.Sprintf("[ocr] WARNING: provider %q is active and takes precedence over llm.* settings.\n"+
"[ocr] Use 'ocr config set providers.%s.<field> <value>' to configure the active provider,\n"+
"[ocr] or run 'ocr config unset provider' to disable provider-based config.\n", provider, provider)
After:
prefix := "providers"
if _, isPreset := llm.LookupProvider(provider); !isPreset {
prefix = "custom_providers"
}
return fmt.Sprintf("[ocr] WARNING: provider %q is active and takes precedence over llm.* settings.\n"+
"[ocr] Use 'ocr config set %s.%s.<field> <value>' to configure the active provider,\n"+
"[ocr] or run 'ocr config unset provider' to disable provider-based config.\n", provider, prefix, provider)
Nice PR โ two small issues:
1. **`legacyLLMShadowWarning`: the `strings.ToLower` on the key causes false-positive warnings** The config system is case-sensitive, so `LLM.url` or `Llm.model` won't actually set a valid config field. But `strings.HasPrefix(strings.ToLower(key), "llm.")` still matches them and emits the shadow warning, which is misleading. Should just be `strings.HasPrefix(key, "llm.")` without the ToLower. 2. **`flags.go:282`: the unset usage error message lost helpful examples** The original error text listed examples for both `custom_providers.<name>` and `mcp_servers.<name>`. The new version only shows `ocr config unset provider` as an example, making it harder for users to discover the other unset targets. Consider keeping at least one example per supported key type.
Done