Skip to content

fix(authentication-azure): record is_url_valid as True, not pickle's TRUE opcode - #786

Merged
Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
HardMax71:fix/azure-is-url-valid-span-attribute
Oct 13, 2026
Merged

Vincent Biret (baywet) merged 1 commit into
microsoft:mainfrom
HardMax71:fix/azure-is-url-valid-span-attribute

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

AzureIdentityAccessTokenProvider imported TRUE from pickle and set the com.microsoft.kiota.authentication.is_url_valid span attribute to it once the URL passed validation. pickle.TRUE is the protocol 0 opcode b"I01\n", not a boolean, so the attribute never recorded True. It looks like an editor auto-import picked it up when observability was added in 2023.

What tracing backends get depends on the OpenTelemetry SDK version:

The package allows opentelemetry-sdk>=1.27.0, so a fresh install today gets the second case. This sets a real True, which matches the False on the failure paths and what kiota-dotnet and kiota-typescript record.

Related Issue

None filed. I found it while typing this package for #722.

Notes

#785 touches the same file, and the two merge cleanly.

Testing Instructions

  • The new test records spans with an in-memory exporter, the same way the http package's span_exporter fixture does, and checks that the attribute is True. On main it fails with assert b'I01\n' is True.
  • yapf -dr, isort, pylint --disable=W, mypy and pytest pass in packages/authentication/azure.

…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.
@sonarqubecloud

Copy link
Copy Markdown

@baywet
Vincent Biret (baywet) requested a balanced review from Copilot October 13, 2026 12:47

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix is correct and has adequate regression coverage.

0 open findings

What changed in this PR

Fixes Azure authentication tracing to record URL validity as a boolean.

Changes:

  • Replaces pickle.TRUE with Python’s True.
  • Adds regression coverage for the span attribute.
File Description
azure_identity_access_token_provider.py Records valid URL telemetry correctly.
test_azure_identity_access_token_provider.py Verifies the attribute is boolean True.

🧠 Review effort: Balanced


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

@baywet
Vincent Biret (baywet) merged commit c383019 into microsoft:main Oct 13, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants