open-telemetry / open-telemetry/opentelemetry-java
EndpointUtil.validateEndpoint not handling all valid DNS host names
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.5k
- Forks
- 1k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 58
Description
Describe the bug
the recent check to validate hostname in EndpointUtils.validateEndpoint() is hitting
https://bugs.openjdk.org/browse/JDK-8188305
that is, URI.getHost() returns null for hostnames that are valid according to modern DNS standards (in my particular case, hostnames w/ a segment that starts with a number).
Steps to reproduce
set otel.exporter.etlp.endpoint to http://otlp.1234-k8s-namespace:4318 (or any other value that triggers the URI.getHost() bug)
What did you expect to see?
normal agent startup
What did you see instead?
io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder - Error encountered during autoconfiguration. Closing partially configured components.
io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException: Unexpected configuration error
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.buildImpl(AutoConfiguredOpenTelemetrySdkBuilder.java:510)
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:431)
...
Caused by: java.lang.IllegalArgumentException: Invalid endpoint, must start with http:// or https://: http://otlp-collector.14014-mosaik:4318/v1/metrics
at io.opentelemetry.exporter.internal.EndpointUtil.validateEndpoint(EndpointUtil.java:34)
at io.opentelemetry.exporter.otlp.internal.HttpExporterBuilder.setEndpoint(HttpExporterBuilder.java:94)
at io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder.setEndpoint(OtlpHttpMetricExporterBuilder.java:127)
What version and what artifacts are you using?
edot-java:1.12.0 (otel-instrumentation:2.30.0; sdk: 1.64.0)
possible workaround
in my particular case, because this was a hostname from a k8s namespace that follows a number-prefix naming convention, I was able to get around the java bug simply by using the service FQDN (otlp.1234-k8s-namespace.svc.cluster.local)
Contributor 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.
Research direction
Start at EndpointUtil.validateEndpoint(), referenced in the stack trace, and reproduce the failure with http://otlp.1234-k8s-namespace:4318. Compare the validation behavior with the linked JDK URI.getHost() issue and verify that valid DNS hostnames with a numeric-starting segment no longer prevent normal agent startup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100