Skip to content

fix: GetConfig/PublishConfig 在 Nacos 2.x 上回退到 v1 API - #99

Open
Mr-Koala wants to merge 1 commit into
nacos-group:mainfrom
Mr-Koala:fix/config-v1-compat
Open

Mr-Koala wants to merge 1 commit into
nacos-group:mainfrom
Mr-Koala:fix/config-v1-compat

Conversation

@Mr-Koala

@Mr-Koala Mr-Koala commented Aug 3, 2026

Copy link
Copy Markdown

问题:login() 与 ListConfigs() 已实现 v3→v1 自动回退,但 GetConfig() 与 PublishConfig() 漏掉了 v1 分支,硬编码走 v3 路径
(/nacos/v3/client/cs/config、/nacos/v3/admin/cs/config)。 Nacos 2.x 服务端不存在这些 v3 路径,导致 config-get/config-set 直接 404。

修复:当 authLoginVersion == "v1" 时回退到 v1 实现,与 listConfigsV1 保持一致的协议差异:

  • 路径:/nacos/v1/cs/configs
  • 参数:group(非 groupName)、tenant(非 namespaceId)
  • 鉴权:accessToken 表单字段(非 Authorization: Bearer 头)
  • 响应:config-set 为字面量 true,config-get 为原始内容

验证:对 Nacos 2.5.1 standalone 服务端,config-set/config-get 均成功, 原始 push.sh 无需改动即可正常工作。

问题:login() 与 ListConfigs() 已实现 v3→v1 自动回退,但 GetConfig()
与 PublishConfig() 漏掉了 v1 分支,硬编码走 v3 路径
(/nacos/v3/client/cs/config、/nacos/v3/admin/cs/config)。
Nacos 2.x 服务端不存在这些 v3 路径,导致 config-get/config-set 直接 404。

修复:当 authLoginVersion == "v1" 时回退到 v1 实现,与 listConfigsV1
保持一致的协议差异:
- 路径:/nacos/v1/cs/configs
- 参数:group(非 groupName)、tenant(非 namespaceId)
- 鉴权:accessToken 表单字段(非 Authorization: Bearer 头)
- 响应:config-set 为字面量 true,config-get 为原始内容

验证:对 Nacos 2.5.1 standalone 服务端,config-set/config-get 均成功,
原始 push.sh 无需改动即可正常工作。
@CLAassistant

CLAassistant commented Aug 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants