Describe the bug
Some situation for openAPI will return wrong status code, such as:
Register one persistent instance for A service first, and then try to register one ephemeral instance to A service.
For expected get an 400 error because a persistent service can't register ephemeral instance, the error message is right.
But the status code is 500.
For research, The reason is the check logic is throw the NacosRuntimeException with 400 errorCode, But the ResponseExceptionHandler in nacos-naming module did not handle NacosRuntimeException type but as normal Exception to handle, which will cause the status code is 500.
Expected behaviorNacosRuntimeException can be handle right and the response status code can same with NacosRuntimeException.
Actually behaviorNacosRuntimeException will all change to 500 code.
Additional context
BTW, expect ResponseExceptionHandler in nacos-naming , other ExceptionHandler such as GlobalExceptionHandler in nacos-config, ConsoleExceptionHandler in nacos-console, PrometheusApiExceptionHandler in nacos-prometheus also should handle NacosRuntimeException.
Describe the bug Some situation for openAPI will return wrong status code, such as:
Register one persistent instance for A service first, and then try to register one ephemeral instance to A service. For expected get an 400 error because a persistent service can't register ephemeral instance, the error message is right. But the status code is 500.
For research, The reason is the check logic is throw the
NacosRuntimeException
with 400 errorCode, But theResponseExceptionHandler
in nacos-naming module did not handleNacosRuntimeException
type but as normalException
to handle, which will cause the status code is 500.Expected behavior
NacosRuntimeException
can be handle right and the response status code can same withNacosRuntimeException
.Actually behavior
NacosRuntimeException
will all change to 500 code.Additional context BTW, expect
ResponseExceptionHandler
in nacos-naming , otherExceptionHandler
such asGlobalExceptionHandler
in nacos-config,ConsoleExceptionHandler
in nacos-console,PrometheusApiExceptionHandler
in nacos-prometheus also should handleNacosRuntimeException
.