Skip to content

fix(naming): Fix the empty cluster name parameter handling logic to ensure the v3 HTTP processing logic is consistent with gRPC.#14674

Open
iggzq wants to merge 6 commits intoalibaba:developfrom
iggzq:fix(14650-http和grpc的listInstances处理逻辑不一致)

Hidden character warning

The head ref may contain hidden characters: "fix(14650-http\u548cgrpc\u7684listInstances\u5904\u7406\u903b\u8f91\u4e0d\u4e00\u81f4)"
Open

fix(naming): Fix the empty cluster name parameter handling logic to ensure the v3 HTTP processing logic is consistent with gRPC.#14674
iggzq wants to merge 6 commits intoalibaba:developfrom
iggzq:fix(14650-http和grpc的listInstances处理逻辑不一致)

Conversation

@iggzq
Copy link
Copy Markdown
Contributor

@iggzq iggzq commented Mar 20, 2026

  • 在CatalogServiceV2Impl中添加对空集群名的验证,当clusterName为空时,不添加此筛选逻辑,与gRPC保持一致
  • 更新listInstances方法中的集群名验证逻辑,使用actualCluster变量处理空字符串情况
  • 移除InstanceListForm中将空集群名转换为默认集群名的逻辑
  • 为GrpcConnection类的sendRequestNoAck方法添加@OverRide注解
  • 为NacosTpsControlManager接口实现类添加缺失的@OverRide注解
  • 更新相关测试用例以验证空集群名参数的正确处理行为

What is the purpose of the change

fix(#14650) : the Nacos v3 API is inconsistent with the gRPC client mechanism.

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check spotbugs:check -DskipTests to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

- 在CatalogServiceV2Impl中添加对空集群名的验证,当clusterName为空时,不添加此筛选逻辑,与gRPC保持一致
- 更新listInstances方法中的集群名验证逻辑,使用actualCluster变量处理空字符串情况
- 移除InstanceListForm中将空集群名转换为默认集群名的逻辑
- 为GrpcConnection类的sendRequestNoAck方法添加@OverRide注解
- 为NacosTpsControlManager接口实现类添加缺失的@OverRide注解
- 更新相关测试用例以验证空集群名参数的正确处理行为
@github-actions
Copy link
Copy Markdown

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

Copy link
Copy Markdown
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

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

pr标题请使用英文。

KomachiSion
KomachiSion previously approved these changes Mar 20, 2026
@KomachiSion KomachiSion self-requested a review March 20, 2026 09:34
@iggzq iggzq changed the title fix(naming): 修复空集群名参数处理逻辑,使得v3 http的处理逻辑与gRPC保持一致 fix(naming): Fix the empty cluster name parameter handling logic to ensure the v3 HTTP processing logic is consistent with gRPC. Mar 20, 2026
- 删除了 InstanceListForm 中未使用的 UtilsAndCommons 导入
- 保持代码整洁性并减少不必要的依赖引入
@iggzq
Copy link
Copy Markdown
Contributor Author

iggzq commented Mar 20, 2026

pr标题请使用英文。
已改变。并且已修复checkstyle问题

iggzq added 3 commits March 21, 2026 11:00
- 将通配符导入替换为具体的JUnit断言方法导入
- 明确导入assertEquals、assertFalse、assertNotNull、assertTrue和assertThrows方法
- 提高代码可读性和维护性
- 遵循最佳实践减少不必要的导入依赖
- 删除了对 clusterName 的冗余验证逻辑
- 保留了实际集群名称的必要验证
- 简化了服务实例选择流程中的条件判断
- 将 listInstances 方法调用中的第四个参数从 anyString() 修改为 any()
- 保持其他参数匹配器不变
- 确保测试方法 getInstanceList 的功能正常运行
@KomachiSion
Copy link
Copy Markdown
Collaborator

修改之后是否会影响到控制台的展示逻辑? 能否帮忙测试一下?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lient/naming/NacosNamingMaintainerServiceImpl.java 0.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@KomachiSion
Copy link
Copy Markdown
Collaborator

Thanks for your this PR. 🙏 Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration. If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io

感谢您提交的PR。 🙏 请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。 如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@iggzq 根据review, 控制台的访问应该不受影响,但是如果用户在使用maintainer-client进行访问或者直接调用api会有行为不同的影响, 需要你更新一下文档进行说明。

文档需改的PR提交无问题后再合并此PR

@wuyfee
Copy link
Copy Markdown

wuyfee commented Mar 24, 2026

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@iggzq
Copy link
Copy Markdown
Contributor Author

iggzq commented Mar 24, 2026

Thanks for your this PR. 🙏 Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration. If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io
感谢您提交的PR。 🙏 请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。 如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@iggzq 根据review, 控制台的访问应该不受影响,但是如果用户在使用maintainer-client进行访问或者直接调用api会有行为不同的影响, 需要你更新一下文档进行说明。

文档需改的PR提交无问题后再合并此PR

ok,晚上我改一下

- 为 listInstances 方法添加带有 clusterName 参数的测试用例
@iggzq
Copy link
Copy Markdown
Contributor Author

iggzq commented Mar 25, 2026

Thanks for your this PR. 🙏 Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration. If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io
感谢您提交的PR。 🙏 请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。 如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@iggzq 根据review, 控制台的访问应该不受影响,但是如果用户在使用maintainer-client进行访问或者直接调用api会有行为不同的影响, 需要你更新一下文档进行说明。

文档需改的PR提交无问题后再合并此PR

已在nacos-group/nacos-group.github.io中修改文档

@wuyfee
Copy link
Copy Markdown

wuyfee commented Mar 25, 2026

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@springcloudconf
Copy link
Copy Markdown

springcloudconf commented Mar 25, 2026 via email

@KomachiSion
Copy link
Copy Markdown
Collaborator

KomachiSion commented Mar 31, 2026

@iggzq 文档已经reivew,有修改意见麻烦更新一下。

}
if (!serviceStorage.getClusters(service).contains(clusterName)) {
throw new NacosException(NacosException.NOT_FOUND, "cluster " + clusterName + " is not found!");
String actualCluster = StringUtils.isBlank(clusterName) ? StringUtils.EMPTY : clusterName;
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.

这一行看起来是多余的。 因为下面有校验是否为blank

@KomachiSion
Copy link
Copy Markdown
Collaborator

@iggzq 给了一点新的评论:

同时建议同步一下develop分支, develop分支优化了一下ci的稳定性。文档的冲突也解决一下。

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.

6 participants