Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- backend, networking
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 29
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from grpc/grpc-java
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
grpc/grpc-java#13063 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
grpc/grpc-java#13052 · 4 comments ·
Maintainers usually reply within 1 day
-
docs enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
grpc/grpc-java#10824 · 8 comments ·
Maintainers usually reply within 1 day
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
grpc/grpc-java#13066 · 5 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
grpc/grpc-java#13065 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
aoqia194/leaf-loader#19 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/streampark#4521 ·
-
Update license yearOpen0 - Backlog 1 - Ready documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
cbor
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
FasterXML/jackson-dataformats-binary#844 ·
Maintainers usually reply within 1 day