refactor(config): extract supported config keys into a single source of truth
Description
In config_cmd.go, the list of supported configuration keys is maintained in two places that must be kept in sync:
- The
switch/casebranches insetConfigValue()(line 361–482) define the actual key handling logic. - The error message in the
defaultcase (line 480) hardcodes a human-readable list of all supported keys.
When a new config key is added, both locations must be updated. If the error message is forgotten, users see an incomplete list of supported keys on typos.
Current code (line 480):
default:
return fmt.Errorf("unknown config key: %s\nSupported keys: provider, model, providers.<name>.<field>, custom_providers.<name>.<field>, mcp_servers.<name>.<field>, llm.url, llm.auth_token, ...", key)
Scope
- File:
cmd/opencodereview/config_cmd.go - Function:
setConfigValue - Extract a
var supportedConfigKeys(or similar) as the single source of truth, and derive the error message from it.
Acceptance Criteria
- [ ] Supported config keys are defined in one place
- [ ] The error message for unknown keys is generated from that definition
- [ ] No change in user-facing behavior (same error message content)
- [ ] Tests pass (
make test) - [ ] Code check passes (
make check)
Context
Discovered during code review of the Cobra CLI migration PR. The switch/case logic itself is correct; this is a maintainability improvement to prevent future drift between the key handling and the help text.
Would love to take this up
I'd like to take this. I've got a patch that pulls the supported keys into a supportedConfigKeys slice and builds the error message from it, keeping the text identical. Opening a PR shortly.