Skip to content

Reject host-less endpoints in EndpointUtil.validateEndpoint#8489

Open
thswlsqls wants to merge 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/endpointutil-reject-hostless-endpoint
Open

Reject host-less endpoints in EndpointUtil.validateEndpoint#8489
thswlsqls wants to merge 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/endpointutil-reject-hostless-endpoint

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Description

  • EndpointUtil.validateEndpoint accepts host-less URIs such as http:localhost:4317 (opaque) and https:/foo (single slash): they have an http/https scheme but no host, so export only fails later at connection time.
  • Add a uri.getHost() == null guard after the scheme check, reusing the existing "must start with http:// or https://" message.
  • The sibling validator OtlpConfigUtil.validateEndpoint (exporters/otlp/all) uses new URL() and already rejects these; this fills the missing case in EndpointUtil's equivalent contract.
  • Behavior change: host-less endpoints that previously passed scheme validation are now rejected.

Testing done

  • Added EndpointUtilTest with valid endpoints (http, https, path, userinfo+host) and invalid ones (opaque http:localhost:4317, single-slash https:/foo, no-scheme localhost, wrong-scheme gopher://localhost).
  • ./gradlew :exporters:common:check — passed; EndpointUtilTest ran 8 tests.
  • internal package, signature unchanged: no apidiff; not user-facing, so no CHANGELOG.

@thswlsqls thswlsqls marked this pull request as ready for review June 20, 2026 00:10
@thswlsqls thswlsqls requested a review from a team as a code owner June 20, 2026 00:10
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 20, 2026

Copy link
Copy Markdown

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

  • ✅ login: thswlsqls / name: Eunbin Son (d00086f)

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.51%. Comparing base (824334c) to head (1a2b01a).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8489      +/-   ##
============================================
- Coverage     78.77%   78.51%   -0.26%     
- Complexity     8579     8602      +23     
============================================
  Files          1009     1013       +4     
  Lines         28993    29150     +157     
  Branches       3599     3632      +33     
============================================
+ Hits          22839    22887      +48     
- Misses         5311     5420     +109     
  Partials        843      843              

☔ 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.

@thswlsqls

Copy link
Copy Markdown
Contributor Author

/easycla

Convert validateEndpoint_invalid from @valuesource to @MethodSource with
named Arguments.argumentSet cases, matching the validEndpoints style in the
same test class. No change to what the test asserts.

Generated-by: Claude Code
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.

2 participants