Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
The issue is in hostname validation using java.net.URI. Look at GrpcUtil.authorityFromHostAndPort and DnsNameResolver. The bug is that valid RFC 1123 hostnames with a digit-starting last label are rejected. Start by examining the validation logic and see how to bypass or replace the URI-based check while maintaining compatibility. Check for existing tests related to hostname validation. 'Done' means the channel builder accepts hostnames like 'otlp.1234-k8s-namespace' without throwing IllegalArgumentException.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of gRPC-Java are you using?
1.84.0 (grpc-netty-shaded)
What is your environment?
JDK 11 / 17 / 21, reproducible on macOS and Linux.
What did you expect to see?
A channel can be built for valid RFC 1123 hostnames whose last label starts with a digit. These are common in Kubernetes, where a service in namespace 1234-k8s-namespace is reachable as otlp.1234-k8s-namespace.
What did you see instead?
| Call | Result |
|---|---|
ManagedChannelBuilder.forAddress("otlp.1234-k8s-namespace", 4317) |
IllegalArgumentException: Invalid host or port |
ManagedChannelBuilder.forTarget("otlp.1234-k8s-namespace:4317") |
IllegalArgumentException: Invalid DNS name |
ManagedChannelBuilder.forTarget("dns:///otlp.1234-k8s-namespace:4317") |
IllegalArgumentException: Invalid DNS name |
ManagedChannelBuilder.forTarget("localhost:4317") |
OK |
GrpcUtil.authorityFromHostAndPort and DnsNameResolver both validate the host with java.net.URI. URI follows RFC 2396, where the last label of a hostname must start with a letter, so URI.getHost() returns null for these names (JDK-8188305). RFC 1123 allows it, and DNS resolves them fine.
The only workaround I found is resolving the address yourself and passing a fixed SocketAddress, which loses re-resolution and load balancing.
Steps to reproduce the bug
ManagedChannelBuilder.forTarget("dns:///otlp.1234-k8s-namespace:4317").usePlaintext().build();
// java.lang.IllegalArgumentException: Invalid DNS name: otlp.1234-k8s-namespace
Downstream context: open-telemetry/opentelemetry-java#8745, where the OTLP exporter's grpc-java sender can't be used with these endpoints.
- Ngôn ngữ chính
- Java
- Star
- 12.1k
- Fork
- 4k
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của grpc/grpc-java
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
grpc/grpc-java#13063 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
grpc/grpc-java#13052 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support of `dns:name` URIsĐang mởdocs enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
grpc/grpc-java#10824 · 8 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của grpc/grpc-java
Issue tương tự
-
ScyllaDB Manual: 3 broken linksĐang mởlink-check link-check:manual
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
open-telemetry/opentelemetry-java#8870 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
P2 testing
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/core kind/bug status/triage team/core-shared
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày