Aias00 opened a new issue, #6519:
URL: https://github.com/apache/shenyu/issues/6519

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/shenyu/issues) and found no similar issues.
   
   ### Apache ShenYu Component
   
   shenyu-admin
   
   ### What happened
   
   `AbstractShenyuClientRegisterServiceImpl.checkNamespacePluginRel(...)` 
intends to report a clear error when a plugin is not enabled for a namespace or 
does not exist:
   
   ```java
   PluginDO pluginDO = pluginMapper.selectByName(pluginName);
   NamespacePluginVO namespacePluginRelation = 
namespacePluginRelMapper.selectByPluginIdAndNamespaceId(pluginDO.getId(), 
namespaceId);
   if (Objects.isNull(namespacePluginRelation)) {
       String errorMsg = String.format("%s plugin not enabled for current 
namespace or plugin not exist for namespaceId: %s", pluginName, namespaceId);
       throw new IllegalArgumentException(errorMsg);
   }
   ```
   
   But if `pluginMapper.selectByName(pluginName)` returns `null`, the next line 
dereferences `pluginDO.getId()` and throws `NullPointerException`. The intended 
diagnostic error is never returned to the registration caller.
   
   This can happen when a client registration path maps to a plugin name that 
is missing from the admin database, or when plugin initialization data is 
incomplete.
   
   ### Expected behavior
   
   `checkNamespacePluginRel(...)` should check whether `pluginDO` is null 
before using `pluginDO.getId()`. Missing plugin records should produce the same 
clear "plugin not enabled or not exist" error instead of an internal 
`NullPointerException`.
   
   ### How to reproduce
   
   1. Start admin with a missing plugin row for a client registration plugin 
name.
   2. Send a client registration request that reaches 
`checkNamespacePluginRel(namespaceId, pluginName)`.
   3. `pluginMapper.selectByName(pluginName)` returns `null`.
   4. The method throws `NullPointerException` at `pluginDO.getId()` instead of 
returning a clear registration error.
   
   ### Debug logs
   
   _No response_
   
   ### Environment
   
   Current `master` branch.
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to