apache / apache/shenyu

[BUG] DiscoveryUpstreamServiceImpl.listAll NPE on null discoveryRel / selector / proxySelector

Open Beginner friendly
#6,699 1 comment 0 reactions 0 assignees View on GitHub
admin priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium
- files: `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryUpstreamServiceImpl.java:149-170`
- description: For each discovery handler, `discoveryRelMapper.selectByDiscoveryHandlerId(d.getId())` is dereferenced immediately at line 154 (`discoveryRelDO.getPluginName()`) and 155 (`discoveryRelDO.getSelectorId()`). If a handler has no rel row, this is an NPE. `selectorMapper.selectById(selectorId)` (158) and `proxySelectorMapper.selectById(proxySelectorId)` (163) are also dereferenced without null checks.
- impact: A single orphan discovery-handler/rel or stale selector-id throws NPE and breaks the whole `listAll` sync (used by `SyncDataServiceImpl.syncAll`).
- suggested_fix: Null-check `discoveryRelDO`, `selectorDO`, and `proxySelectorDO` and skip/log.
- confidence: Medium
- related_existing: #6586 covers the N+1 query pattern in this method; these NPE derefs are a distinct defect in the same method.

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Read shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryUpstreamServiceImpl.java:149-170, focusing on listAll and its mapper lookups. Trace how SyncDataServiceImpl.syncAll uses this result, then verify that missing discovery relationships or selectors no longer abort the sync and are handled consistently with the intended skip/log behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.