From d4968ca65912ad933e176237c319c2af9531f13a Mon Sep 17 00:00:00 2001 From: HardMax71 Date: Sat, 10 Oct 2026 12:12:19 +0200 Subject: [PATCH] fix(authentication-azure): record is_url_valid as True, not pickle's TRUE opcode The module imported TRUE from pickle, which is the bytes b"I01\n", and set the is_url_valid span attribute to it when the URL passed validation. OpenTelemetry SDKs before 1.45.0 decode bytes, so the attribute read "I01\n". Since 1.45.0 they keep the bytes, which ConsoleSpanExporter can't serialize, so the whole get_authorization_token span is dropped. Set a real True, matching the False on the failure paths. --- .../azure_identity_access_token_provider.py | 3 +-- ...est_azure_identity_access_token_provider.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/authentication/azure/kiota_authentication_azure/azure_identity_access_token_provider.py b/packages/authentication/azure/kiota_authentication_azure/azure_identity_access_token_provider.py index d116f29e..e03b03d7 100644 --- a/packages/authentication/azure/kiota_authentication_azure/azure_identity_access_token_provider.py +++ b/packages/authentication/azure/kiota_authentication_azure/azure_identity_access_token_provider.py @@ -1,6 +1,5 @@ import base64 import inspect -from pickle import TRUE from typing import Any, Optional, Union from urllib.parse import urlparse @@ -85,7 +84,7 @@ async def get_authorization_token( span.record_exception(exc) raise exc - span.set_attribute(self.IS_VALID_URL, TRUE) + span.set_attribute(self.IS_VALID_URL, True) decoded_claim = None if all( diff --git a/packages/authentication/azure/tests/test_azure_identity_access_token_provider.py b/packages/authentication/azure/tests/test_azure_identity_access_token_provider.py index c4c219fa..512707b5 100644 --- a/packages/authentication/azure/tests/test_azure_identity_access_token_provider.py +++ b/packages/authentication/azure/tests/test_azure_identity_access_token_provider.py @@ -2,6 +2,9 @@ import pytest from kiota_abstractions.authentication import AllowedHostsValidator +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import SimpleSpanProcessor +from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter from kiota_authentication_azure.azure_identity_access_token_provider import ( AzureIdentityAccessTokenProvider, @@ -109,6 +112,21 @@ async def test_get_authorization_token_sync(): assert token == "This is a dummy token" +@pytest.mark.asyncio +async def test_get_authorization_token_marks_valid_url_span_attribute_true(monkeypatch): + exporter = InMemorySpanExporter() + provider = TracerProvider() + provider.add_span_processor(SimpleSpanProcessor(exporter)) + monkeypatch.setattr( + "kiota_authentication_azure.azure_identity_access_token_provider.tracer", + provider.get_tracer(__name__) + ) + token_provider = AzureIdentityAccessTokenProvider(DummySyncAzureTokenCredential(), None) + await token_provider.get_authorization_token('https://graph.microsoft.com') + [span] = exporter.get_finished_spans() + assert span.attributes[AzureIdentityAccessTokenProvider.IS_VALID_URL] is True + + @pytest.mark.asyncio async def test_get_authorization_token_invalid_url():