Skip to content

Handle bracketed IPv6 hosts in ForwardedHostAddressAndPortExtractor - #20393

Merged
trask merged 2 commits into
open-telemetry:mainfrom
andrewstellman:forwarded-host-ipv6
Oct 16, 2026
Merged

trask merged 2 commits into
open-telemetry:mainfrom
andrewstellman:forwarded-host-ipv6

Conversation

@andrewstellman

Copy link
Copy Markdown
Contributor

Follow-up to #15158 / #19540.

#19540 taught HostAddressAndPortExtractor to parse a bracketed IPv6 authority, but the sibling
ForwardedHostAddressAndPortExtractor still splits at the first :. That is the extractor
HttpServerAttributesExtractor uses for server.address / server.port from the Forwarded host=
parameter, X-Forwarded-Host, :authority and Host, so a server request with
Host: [2001:db8::1]:8080 currently gets server.address = "[2001" and no server.port
(Host: [::1]:8080 gives "[").

This adds the same […] branch used in HostAddressAndPortExtractor and in the for= parsing of
HttpServerAddressAndPortExtractor: the address is the text inside the brackets and the port is parsed
after ]:.

One behavior change for malformed values: an unterminated [ (for example Host: [::1) is now
treated as malformed, like an unterminated quote, so the extractor falls through to the next header
source instead of recording server.address = "[".

Tests:

  • new rows in ForwardedHostAddressAndPortExtractorTest for Host / X-Forwarded-Host / :authority
    and quoted Forwarded: host="[...]" (RFC 7239 requires IPv6 values to be quoted)
  • HttpServerAttributesExtractorTest.shouldExtractIpv6ServerAddressAndPortFromHostHeader (attribute-level)

Before the fix the new cases fail with e.g. expected: "2001:db8::1" but was: "[2001".

Found by Quality Playbook, an AI code-review tool, and fixed with Claude (Opus 5.5); I reviewed the change and the tests.

The host value was split at the first ':', so Host: [::1]:8080 gave
server.address "[" and no server.port. Parse [...] the same way
HostAddressAndPortExtractor does.

Assisted-by: Claude Opus 5.5
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged Β· refreshed 2026-10-16 02:02 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@andrewstellman
andrewstellman marked this pull request as ready for review October 5, 2026 18:24
@andrewstellman
andrewstellman requested a review from a team as a code owner October 5, 2026 18:24
Copilot AI balanced review requested due to automatic review settings October 5, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟒 Approval recommended

The parsing change is focused, consistent with sibling extractors, and adequately tested.

Review effort: Balanced
Findings: None

What changed in this PR

Adds bracketed IPv6 parsing for forwarded HTTP host authorities while preserving header fallback behavior.

Changes:

  • Extracts IPv6 addresses and optional ports from bracketed authorities.
  • Rejects unterminated bracketed values.
  • Adds extractor-level and attribute-level regression coverage.
File Description
ForwardedHostAddressAndPortExtractor.java Parses bracketed IPv6 hosts and ports.
ForwardedHostAddressAndPortExtractorTest.java Covers supported headers and malformed input.
HttpServerAttributesExtractorTest.java Verifies emitted IPv6 server attributes.

πŸ’‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@andrewstellman

Copy link
Copy Markdown
Contributor Author

/dashboard route:reviewers

The only non-passing job is a cancelled shard, common / test2 (11, hotspot, indy false); the other 91 checks pass. Could someone with access rerun it?

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

@andrewstellman, this pull request was routed to reviewers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open.

@laurit laurit added this to the v3.0.0 milestone Oct 13, 2026
@trask
trask merged commit 4c07f4d into open-telemetry:main Oct 16, 2026
68 checks passed
@trask

trask commented Oct 16, 2026

Copy link
Copy Markdown
Member

Thanks!

@otelbot

otelbot Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @andrewstellman! πŸŽ‰ We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

4 participants