[BUG] GrpcParser and DubboIngressParser NPE when referenced k8s Service has no Endpoints
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
Both `GrpcParser` and `DubboIngressParser` call `endpointsLister.namespace(namespace).get(serviceName)` and immediately dereference the result with `.getSubsets()` without a null check. If the referenced Service exists but has no Endpoints yet (common during rolling deployments, scale-down, or misconfiguration), the lister returns null and `.getSubsets()` throws NPE. The sibling parsers `DivideIngressParser` (line 156-157) and `WebSocketParser` (line 155-156) correctly guard with `if (Objects.isNull(v1Endpoints))`.
## Location
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/GrpcParser.java:155-156,186-187`
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java:161-162,337-338`
## Impact
Creating or updating a gRPC/Dubbo ingress whose backing Service has no ready Endpoints crashes the reconcile cycle with an unhandled NPE, preventing the ingress from being configured at all.
## Suggested fix
Add `if (Objects.isNull(v1Endpoints)) { LOG.info("Endpoints {} not found", serviceName); return upstreamList; }` after each `endpointsLister...get(serviceName)`, mirroring `DivideIngressParser`.
## Related existing
None — GOV-T6 (#6679) covers the parsers having zero tests; this is the concrete runtime NPE.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the four locations in GrpcParser.java and DubboIngressParser.java, then compare their endpoint handling with DivideIngressParser.java and WebSocketParser.java. Verify that each missing-Endpoints path returns without an NPE and that existing endpoint handling remains unchanged; the issue does not name test files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kubernetes
- Domain
- backend, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100