Skip to content

OTel exporter endpoint URL doesn't bracket IPv6 host literals #66811

@1fanwang

Description

@1fanwang

Apache Airflow version

main (development)

What happened?

get_otel_data_exporter() in shared/observability/src/airflow_shared/observability/common.py builds the OTLP exporter endpoint URL with a raw f-string:

endpoint_str = f"{protocol}://{host}:{port}/v1/{endpoint_suffix}"

If host is an IPv6 literal (e.g. ::1, 2001:db8::1), the resulting URL is invalid per RFC 3986 §3.2.2:

http://::1:4318/v1/metrics              # invalid — needs http://[::1]:4318/...
http://2001:db8::1:4318/v1/metrics      # invalid — needs http://[2001:db8::1]:4318/...

The OTLP exporter then either fails to parse the URL or interprets the trailing port digits as part of the v6 address.

What you think should happen instead?

Bracket IPv6 host literals before concatenating with the port. RFC 3986 §3.2.2 requires [...] around v6 hosts in the URI authority.

How to reproduce

Set the OTel collector host to a literal IPv6 address (via OTEL_EXPORTER_OTLP_ENDPOINT_HOST=::1 and the corresponding port var, or the deprecated [metrics] otel_host = ::1 config option), enable OTel metrics, and observe the exporter fails to reach the collector.

Anything else?

Affects deployments where the collector is reachable only via IPv6 — uncommon today but growing as IPv6-only k8s networks become more common.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions