Repository navigation
Handle bracketed IPv6 hosts in ForwardedHostAddressAndPortExtractor - #20393
Conversation
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
Pull request dashboard statusMerged Β· refreshed 2026-10-16 02:02 UTC Status above doesn't look right?
|
There was a problem hiding this comment.
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.
|
/dashboard route:reviewers The only non-passing job is a cancelled shard, |
|
@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. |
|
Thanks! |
|
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. |
Follow-up to #15158 / #19540.
#19540 taught
HostAddressAndPortExtractorto parse a bracketed IPv6 authority, but the siblingForwardedHostAddressAndPortExtractorstill splits at the first:. That is the extractorHttpServerAttributesExtractoruses forserver.address/server.portfrom theForwardedhost=parameter,
X-Forwarded-Host,:authorityandHost, so a server request withHost: [2001:db8::1]:8080currently getsserver.address = "[2001"and noserver.port(
Host: [::1]:8080gives"[").This adds the same
[β¦]branch used inHostAddressAndPortExtractorand in thefor=parsing ofHttpServerAddressAndPortExtractor: the address is the text inside the brackets and the port is parsedafter
]:.One behavior change for malformed values: an unterminated
[(for exampleHost: [::1) is nowtreated as malformed, like an unterminated quote, so the extractor falls through to the next header
source instead of recording
server.address = "[".Tests:
ForwardedHostAddressAndPortExtractorTestforHost/X-Forwarded-Host/:authorityand 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.