From 2ea6f46f81ab074dc68ea740118eb6adf6e81782 Mon Sep 17 00:00:00 2001 From: Fernando Date: Wed, 1 Jul 2026 17:41:44 -0300 Subject: [PATCH] opentelemetry-exporter-otlp-proto-http: fix certificate_file=False being ignored The constructor used which caused an explicitly passed False value to be discarded due to Python's falsy evaluation. Use check instead so that False (disable SSL verification) is respected. --- .changelog/5379.fixed | 1 + .../otlp/proto/http/trace_exporter/__init__.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changelog/5379.fixed diff --git a/.changelog/5379.fixed b/.changelog/5379.fixed new file mode 100644 index 00000000000..21e0a6ddd3f --- /dev/null +++ b/.changelog/5379.fixed @@ -0,0 +1 @@ +`opentelemetry-exporter-otlp-proto-http`: fix `certificate_file=False` being ignored due to falsy check diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py index 2be240103c0..974f34372ed 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py @@ -73,7 +73,7 @@ class OTLPSpanExporter(SpanExporter): def __init__( self, endpoint: str | None = None, - certificate_file: str | None = None, + certificate_file: str | bool | None = None, client_key_file: str | None = None, client_certificate_file: str | None = None, headers: dict[str, str] | None = None, @@ -90,9 +90,13 @@ def __init__( environ.get(OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_ENDPOINT) ), ) - self._certificate_file = certificate_file or environ.get( - OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE, - environ.get(OTEL_EXPORTER_OTLP_CERTIFICATE, True), + self._certificate_file = ( + certificate_file + if certificate_file is not None + else environ.get( + OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE, + environ.get(OTEL_EXPORTER_OTLP_CERTIFICATE, True), + ) ) self._client_key_file = client_key_file or environ.get( OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY,