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

refactor(config): extract supported config keys into a single source of truth

Open DoTuanAnh2k1 opened this issue 4 months ago • 2 comments

setConfigValue kept the list of supported top-level config keys in two places — the switch/case branches and, hardcoded again, the "Supported keys:" line of the unknown-key error. Adding a key meant updating both, and it was easy to forget the error text.

This moves the keys into a supportedConfigKeys slice and builds the "Supported keys:" part of the message from it with strings.Join, so the two can't drift. The message content is byte-for-byte unchanged.

Added TestSetConfigValueUnknownKeyMessage, which pins the full message and checks it is generated from supportedConfigKeys. go test ./... and make check pass.

Closes #637


Disclosure: prepared with AI assistance.

DoTuanAnh2k1 avatar Jul 31 '26 15:07 DoTuanAnh2k1

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 31 '26 15:07 CLAassistant

✅ OpenCodeReview: No comments generated. Looks good to me.

github-actions[bot] avatar Jul 31 '26 18:07 github-actions[bot]