[ISSUE #14094] fix(naming): validate serviceName and groupName in SubscribeServiceRequestHandler#14099
Conversation
… to return 400 instead of 500 When gRPC subscribe request contains blank serviceName or groupName, NamingUtils.getGroupedName() throws IllegalArgumentException which is incorrectly returned as 500 error code. This causes SDK clients to retry infinitely and eventually become UNHEALTHY. Add parameter validation in SubscribeServiceRequestHandler to throw NacosException with INVALID_PARAM (400) error code before calling getGroupedName(), allowing SDK to distinguish client errors from server errors. Fixes alibaba#14094
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
|
|
|
@shichaoyuan |
I will re-run the ci |
OK, I will check it based on the results of this run. |
It looks like the MemoryMcpCacheIndexTest test case isn't robust enough |
… to return 400 instead of 500 (alibaba#14099) When gRPC subscribe request contains blank serviceName or groupName, NamingUtils.getGroupedName() throws IllegalArgumentException which is incorrectly returned as 500 error code. This causes SDK clients to retry infinitely and eventually become UNHEALTHY. Add parameter validation in SubscribeServiceRequestHandler to throw NacosException with INVALID_PARAM (400) error code before calling getGroupedName(), allowing SDK to distinguish client errors from server errors. Fixes alibaba#14094
… to return 400 instead of 500 (#14099) When gRPC subscribe request contains blank serviceName or groupName, NamingUtils.getGroupedName() throws IllegalArgumentException which is incorrectly returned as 500 error code. This causes SDK clients to retry infinitely and eventually become UNHEALTHY. Add parameter validation in SubscribeServiceRequestHandler to throw NacosException with INVALID_PARAM (400) error code before calling getGroupedName(), allowing SDK to distinguish client errors from server errors. Fixes #14094
Summary
serviceNameandgroupNameinSubscribeServiceRequestHandlerbefore callingNamingUtils.getGroupedName()NacosExceptionwithINVALID_PARAM(400) error code instead of lettingIllegalArgumentExceptionpropagate as 500 errorRoot Cause
When gRPC subscribe request contains blank
serviceNameorgroupName,NamingUtils.getGroupedName()throwsIllegalArgumentException. TheErrorResponse.build(Throwable)method treats this as an unknown exception and returns error code 500 (FAIL). This causes SDK clients to:Solution
Validate parameters in the handler before calling
getGroupedName(), throwingNacosExceptionwithINVALID_PARAM(400) error code. This allows:Test plan
Fixes #14094