Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- backend, networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 1h
- PR unite (30g)
- 31
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di grpc/grpc-java
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
grpc/grpc-java#13063 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
grpc/grpc-java#13052 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Support of `dns:name` URIsApertadocs enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
grpc/grpc-java#10824 · 8 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 70/100
grpc/grpc-java#13078 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
question
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
grpc/grpc-java#13066 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di grpc/grpc-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
github/copilot-sdk#2793 ·
I maintainer di solito rispondono entro 1 giorno
-
Unify jpa4 into orm8Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
enhancement good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100