Skip to content

Accept RFC 1123 hostnames in EndpointUtil.validateEndpoint - #8746

Open
kalayciburak wants to merge 1 commit into
open-telemetry:mainfrom
kalayciburak:fix/endpoint-rfc1123-host
Open

Accept RFC 1123 hostnames in EndpointUtil.validateEndpoint#8746
kalayciburak wants to merge 1 commit into
open-telemetry:mainfrom
kalayciburak:fix/endpoint-rfc1123-host

Conversation

@kalayciburak

Copy link
Copy Markdown

Description

EndpointUtil.validateEndpoint rejects hostnames that java.net.URI#getHost() cannot parse even when they are valid DNS names. That is JDK-8188305: RFC 2396 host parsing returns null for labels that start with a digit, which is common for Kubernetes namespaces such as otlp.1234-k8s-namespace.

The existing uri.getHost() == null check was added in #8489 to reject truly host-less URIs (http:localhost:4317, https:/foo). That check is still needed, but it is too strict when getHost() is null and a host is present.

This falls back to URL.getHost(), the same parser used by OtlpConfigUtil.validateEndpoint. Host-less URIs still fail; RFC 1123 names that URI.getHost() misses are accepted.

Fixes #8745

Testing done

  • ./gradlew :exporters:common:test --tests io.opentelemetry.exporter.internal.EndpointUtilTest — 12 tests, 0 failed
    • RED: the three new RFC 1123 cases failed on URI.getHost() == null before the change
    • GREEN: all 12 pass after the fallback
  • ./gradlew :exporters:common:check — passed (tests, checkstyle, spotless, japicmp, animalsniffer)

URI.getHost() returns null for some valid DNS names (JDK-8188305),
such as a label that starts with a digit. Fall back to URL.getHost()
so those endpoints are accepted, matching OtlpConfigUtil.

Fixes open-telemetry#8745

Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
@kalayciburak
kalayciburak requested a review from a team as a code owner August 25, 2026 11:49
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 25, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: kalayciburak / name: Burak KALAYCI (69f1520)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 25, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-02 14:35 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69f1520108

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"Invalid endpoint, must start with http:// or https://: " + uri);
}
if (uri.getHost() == null) {
if (!hasHost(uri, endpoint)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve a usable host for accepted endpoints

When this fallback is taken, including for the three new test cases, the method still returns the original URI, whose getHost() is null and whose getPort() is -1. Supported consumers cannot use that representation: JdkHttpSender.java:198 passes it to HttpRequest.Builder.uri, which throws IllegalArgumentException: unsupported URI, while UpstreamGrpcSenderProvider.java:71 passes the null host and invalid port to ManagedChannelBuilder.forAddress. Consequently, these newly accepted endpoints still fail whenever the JDK HTTP or managed-channel gRPC sender is selected; the parsed host and port must be preserved or those consumers must use a parser that supports these names.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.28%. Comparing base (e2efec5) to head (69f1520).

Files with missing lines Patch % Lines
.../opentelemetry/exporter/internal/EndpointUtil.java 57.14% 2 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (57.14%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8746      +/-   ##
============================================
- Coverage     91.29%   91.28%   -0.01%     
- Complexity    10498    10501       +3     
============================================
  Files          1006     1006              
  Lines         28338    28344       +6     
  Branches       3581     3582       +1     
============================================
+ Hits          25870    25873       +3     
- Misses         1675     1677       +2     
- Partials        793      794       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @kalayciburak — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard routes it onward once nothing on the list is waiting on you.
  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.

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.

EndpointUtil.validateEndpoint not handling all valid DNS host names

1 participant