Repository navigation
Description
OpenCodeReview Version
open-code-review v1.12.12 (182898cf) linux/amd64
Operating System
Linux (x86_64)
Installation Method
npm (global)
LLM Provider
Other OpenAI-compatible endpoint
Bug Description
Nested ocr config set providers.<name>.<field> splits the key on the first . after the prefix, so any provider name containing a dot parses the tail of that name as the field name and fails with unknown provider field. Every field is affected, not just one: url, protocol, model and api_key_cmd all fail identically for the same name.
The non-nested path ocr config set provider <name> has no such restriction and succeeds, writing "mimo-v2.6-flash": {} into custom_providers. The result is a config whose active provider points at an entry that no ocr config set invocation can populate — the only recovery is editing config.json by hand. So this is not just an inconvenient error message; the CLI can put a user's configuration into a state it cannot repair.
This name shape is the common one. Naming a custom gateway after the model it serves produces exactly such identifiers: mimo-v2.6-flash, kimi-k2.5, deepseek-v3.2, qwen3.5-plus. And docs/en/configuration.md §Custom providers requires only url + protocol, stating no naming constraint — nothing warns a user away from a name the CLI cannot address.
Steps to Reproduce
Runs entirely in a throwaway HOME; it never reads or writes the real ~/.opencodereview/config.json.
#!/usr/bin/env bash
set -u
export HOME="$(mktemp -d)"; echo "scratch HOME: $HOME"
export OCR_NO_UPDATE=1
ocr config set provider mimo-v2.6-flash
ocr config set custom_providers.mimo-v2.6-flash.url https://example.invalid/v1
ocr config set custom_providers.mimo-v2.6-flash.protocol openai
ocr config set custom_providers.mimo-v2.6-flash.model some-model
echo "--- nested field on a dotted name ---"
ocr config set custom_providers.mimo-v2.6-flash.api_key_cmd 'secret-tool lookup service x'
echo "rc=$?"
echo "--- resulting config.json ---"
python3 -c "import json,os;print(json.dumps(json.load(open(os.path.expanduser('~/.opencodereview/config.json'))),indent=2))"
echo "--- dot-free control ---"
ocr config set custom_providers.mimo-v2-flash.url https://example.invalid/v1
ocr config set custom_providers.mimo-v2-flash.api_key_cmd 'secret-tool lookup service y'
echo "rc=$?"Expected Behavior
ocr config set custom_providers.mimo-v2.6-flash.<field> …should store the value under themimo-v2.6-flashentry, the same wayocr config unset custom_providers.mimo-v2.6-flashalready addresses that entry (see the asymmetry below).- If dotted names are genuinely unsupported, then
ocr config set provider mimo-v2.6-flashshould reject them too, with a message stating the constraint — instead of exit 0 plus a write that creates an entry the tool can never fill.
Concretely, providers.<name>.<field> resolves the name to mimo-v2 and the field to 6-flash.api_key_cmd; it should resolve the name to mimo-v2.6-flash and the field to api_key_cmd.
Logs / Error Output
Verbatim from a real run (the trailing "supported fields are …" list is identical on all four errors and elided here for width):
Set provider = mimo-v2.6-flash
Error: unknown provider field "6-flash.url": supported fields are api_key, api_key_cmd, url, protocol, model, models, auth_header, timeout_sec, extra_body, extra_headers, retry_codes, aws_region, aws_profile
Error: unknown provider field "6-flash.protocol": supported fields are …
Error: unknown provider field "6-flash.model": supported fields are …
--- nested field on a dotted name ---
Error: unknown provider field "6-flash.api_key_cmd": supported fields are …
rc=1
--- resulting config.json ---
{
"provider": "mimo-v2.6-flash",
"custom_providers": {
"mimo-v2.6-flash": {}
},
"llm": {}
}
--- dot-free control ---
Set custom_providers.mimo-v2-flash.url = https://example.invalid/v1
Set custom_providers.mimo-v2-flash.api_key_cmd = secret-tool lookup service y
rc=0
Asymmetry that points at the fix: ocr config unset custom_providers.mimo-v2.6-flash succeeds on that same dotted name and removes the entry, clearing provider and model as a side effect (WARNING: active provider was deleted; 'provider' and 'model' have been cleared). The key grammar therefore already expresses dotted names on one code path; only the nested setter's parser is too narrow.
before unset: {"provider":"mimo-v2.6-flash","custom_providers":{"mimo-v2.6-flash":{},"mimo-v2-flash":{…}}}
after unset: provider=null model=null custom_providers={"mimo-v2-flash":{…}}
AI/LLM Disclosure
- I didn't use AI/LLM to assist or generate the content above.
Left unchecked deliberately — AI assistance was used. Full statement in Additional Context.
Additional Context
Root cause
// cmd/opencodereview/config_cmd.go:997-1003 (setProviderValue); same shape at :1016-1024 (setCustomProviderValue)
parts := strings.SplitN(key, ".", 3) // "custom_providers" | "mimo-v2" | "6-flash.api_key_cmd"
…
return setCustomProviderField(cfg, parts[1], parts[2], key, value) // applyProviderField → default: unknown provider fieldSplitN with n=3 pushes the remaining dots into the field segment. There is no quoting or escape syntax. config_cmd_test.go contains no key with a two-segment provider name, so nothing covers this shape. The code is unchanged on main as of 2026-10-06.
Three possible fixes
- Right-anchored split (recommended). The field set is closed —
api_key,api_key_cmd,url,protocol,model,models,auth_header,timeout_sec,extra_body,extra_headers,retry_codes,aws_region,aws_profile. Match the longest suffix against that table and treat everything between the prefix and the field as the name. Backward compatible, roughly fifteen lines, no change to the CLI surface. One guard needed: a name whose tail collides with a field name (foo.api_key) must be rejected or resolved explicitly. - Reject dotted names consistently, on both
provider <name>and the nested path, with a message stating the constraint, and document it in §Custom providers. Smaller diff, but it makes existing dotted configs unreachable and is a worse user outcome than (1). - Escape syntax, e.g.
custom_providers.mimo\-v2\.6\-flash.url. Most work, changes the input contract, and would needcli_reference_compare_docs_test.goplus both documentation locales updated.
I am happy to send a PR for (1), failing test first, if you would rather not take it yourselves — noting that #1092 and #1484 were both handled quickly by maintainers, so I am defaulting to reporting.
Prior searches
gh search issues --repo alibaba/open-code-review --match title,body for unknown provider field, dot in provider name, provider name with dots, custom provider name, config set nested key, config set escaping, SplitN provider, mimo-v2.6 → all 0 hits.
Closest in spirit is #1092 (closed, completed): a typo'd provider name silently creates a phantom entry through auxiliary fields. This report is different — the name is intentional and valid, the entry is created by the primary provider path, and every subsequent field write fails. #1484 (OCR_CONFIG_PATH divergence) is unrelated and was already removed by #1537.
Environment
Linux x86-64, ocr v1.12.12 installed via npm global (@alibaba-group/open-code-review), git 2.4x, OCR_NO_UPDATE=1 set during the reproduction.
AI/LLM usage statement
This report, the reproduction script, the quoted source lines and the issue searches were produced with an AI coding agent — Xiaoman (小满), model qwen3.8-flash, operating through Qoder CLI. Every command was executed on the machine described above, and every quoted output and source line was read and verified by the author before submission; the text was reviewed end to end rather than pasted through, per CONTRIBUTING.md.
Activity