[BUG] Kubernetes RPC ingress parsers can throw NPE when labels or services are missing
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
### Current Behavior
The Kubernetes RPC ingress parsers assume ingress labels and label-referenced services are always present.
For Dubbo, gRPC, and Sofa route parsing, the code iterates `labels.keySet()` and then immediately dereferences the service returned by `serviceLister.namespace(namespace).get(labels.get(label))`:
```java
for (String label : labels.keySet()) {
Map metadataAnnotations = serviceLister.namespace(namespace)
.get(labels.get(label))
.getMetadata()
.getAnnotations();
...
}
```
If an ingress has rules but no labels, `labels` can be `null`. If a label points to a service name that is not currently present in the local cache, `serviceLister...get(...)` can return `null`. Both cases can throw `NullPointerException` during reconciliation.
### Expected Behavior
The parsers should handle missing labels or missing referenced services gracefully, for example by skipping that metadata/rule entry and allowing a later reconcile after the service cache is populated.
### Steps to Reproduce
1. Create a Dubbo, gRPC, or Sofa ingress with `spec.rules` but without metadata labels expected by the parser, or with a label value that references a service not present in the controller cache.
2. Let the Shenyu Kubernetes controller reconcile it.
3. The parser can throw while iterating labels or reading service metadata annotations.
### Code Location
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java`
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/GrpcParser.java`
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/SofaParser.java`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.