Skip to content

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

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
DoTuanAnh2k1:refactor/config-keys-single-source
Aug 1, 2026
Merged

refactor(config): extract supported config keys into a single source of truth#655
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
DoTuanAnh2k1:refactor/config-keys-single-source

Conversation

@DoTuanAnh2k1

Copy link
Copy Markdown
Contributor

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.

…of truth

The supported top-level config keys lived both in the switch/case in setConfigValue and, hardcoded again, in the unknown-key error message, so adding a key meant updating two places. Move them into a supportedConfigKeys slice and generate the error message from it. The message content is unchanged.

Closes alibaba#637
@CLAassistant

CLAassistant commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: No comments generated. Looks good to me.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 230c6e7 into alibaba:main Aug 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants