apache / apache/shenyu

[BUG] DubboIngressParser.parseUpstream NPE on null annotations / missing key / null backend guard

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

Description

## Description
Line 335: the null guard `Objects.nonNull(path) && Objects.nonNull(path.getBackend().getService())` calls `path.getBackend().getService()` without first checking `path.getBackend()` for null — if `getBackend()` is null, the guard itself NPEs. Line 339: `annotations.get(IngressConstants.UPSTREAMS_PROTOCOL_ANNOTATION_KEY).split(",")` — (a) `annotations` is passed from `ingress.getMetadata().getAnnotations()` which can be null (ingress with no annotations); (b) even if non-null, `.get()` returns null when the annotation is absent, and `.split(",")` on null NPEs. Contrast with `DivideIngressParser` (line 306) which null-guards both `annotations` and the key before splitting.

## Location
- `shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java:335,339`

## Impact
A Dubbo ingress without the `upstreams-protocol` annotation (the common case) NPEs during reconcile, preventing Dubbo routing from being configured.

## Suggested fix
Fix the guard to `Objects.nonNull(path) && Objects.nonNull(path.getBackend()) && Objects.nonNull(path.getBackend().getService())`. Guard line 339 with `if (Objects.nonNull(annotations) && annotations.containsKey(KEY))` before splitting, defaulting to `null` protocol (as `DivideIngressParser` does).

## Related existing
None — distinct from #6598 and GOV-T6 (#6679).

Contributor guide

No contributing guide indexed for this repository

Research direction

Open shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java around lines 335 and 339, then compare the null handling in DivideIngressParser around line 306. Verify that null backends, missing annotations, and absent upstreams-protocol keys no longer cause reconciliation to fail, with a null protocol used when the annotation is absent.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.