Skip to content

fix: prevent NPE in gRPC, Dubbo and Sofa ingress parsers (#6861) - #7057

Open
juicewcode wants to merge 3 commits into
apache:masterfrom
juicewcode:fix/6861-k8s-rpc-parser-labels-npe
Open

juicewcode wants to merge 3 commits into
apache:masterfrom
juicewcode:fix/6861-k8s-rpc-parser-labels-npe

Conversation

@juicewcode

Copy link
Copy Markdown
Contributor

Fixes #6861

Summary

  • Prevent null pointer exceptions when gRPC, Dubbo, or Sofa ingress resources have no labels.
  • Skip label entries whose referenced Kubernetes Service does not exist.
  • Add null-safety tests for all three ingress parsers.

Test

  • Added RpcIngressParserNullSafetyTest.
  • Covered normal parsing with an existing Service.
  • Covered missing Service references.
  • Covered ingress resources with null labels.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

  Guard against null ingress labels before iterating over them, and skip labels
  that reference a missing Kubernetes Service. Add unit tests covering existing
  Services, missing Services, and ingress resources without labels.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR hardens gRPC, Dubbo, and Sofa ingress parsing against missing labels and referenced Services.

Changes:

  • Added null checks for ingress labels.
  • Skipped missing Service references.
  • Added shared null-safety tests for all three parsers.
File summaries
File Description
shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/parser/RpcIngressParserNullSafetyTest.java Updated as part of this pull request.
shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/SofaParser.java Updated as part of this pull request.
shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/GrpcParser.java Updated as part of this pull request.
shenyu-kubernetes-controller/src/main/java/org/apache/shenyu/k8s/parser/DubboIngressParser.java Updated as part of this pull request.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if (Objects.isNull(service)) {
continue;
}
Map<String, String> metadataAnnotations = service.getMetadata().getAnnotations();
if (Objects.isNull(service)) {
continue;
}
Map<String, String> metadataAnnotations = service.getMetadata().getAnnotations();
if (Objects.isNull(service)) {
continue;
}
Map<String, String> metadataAnnotations = service.getMetadata().getAnnotations();

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as PMC (Aias00). Small, well-scoped fix with regression tests; green CI, mergeable. Reviewed the diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Grpc/Dubbo/Sofa parser NPE on null labels + 4-deep service deref chain

3 participants