Skip to content

Telemetry: unwrap TokenFederationProvider to report inner auth mech/flow#781

Merged
samikshya-db merged 3 commits intomainfrom
telemetry-token-federation-auth
Apr 28, 2026
Merged

Telemetry: unwrap TokenFederationProvider to report inner auth mech/flow#781
samikshya-db merged 3 commits intomainfrom
telemetry-token-federation-auth

Conversation

@samikshya-db
Copy link
Copy Markdown
Contributor

Summary

  • TokenFederationProvider wraps an inner auth provider (PAT, OAuth, M2M / ExternalAuthProvider) and only layers a token-exchange step on top. TelemetryHelper.get_auth_mechanism / get_auth_flow previously had no branch for it, so federated connections fell through to AuthMech.OTHER with no flow — hiding the actual auth method.
  • Detect TokenFederationProvider in both helpers and recurse on external_provider. Federated PAT now reports PAT, federated M2M reports OTHER + CLIENT_CREDENTIALS, federated OAuth reports OAUTH + the appropriate flow.
  • Added a unit test covering the three wrap cases.

Test plan

  • poetry run pytest tests/unit/test_telemetry.py::TestTelemetryHelper -v (4 passed, including new test_token_federation_unwraps_to_inner_provider)

This pull request and its description were written by Isaac.

…tion

TokenFederationProvider wraps an underlying auth provider (PAT, OAuth, M2M)
and only adds a token-exchange step. The telemetry helpers previously fell
through to AuthMech.OTHER with no flow, hiding the actual auth method.
Unwrap and recurse on external_provider so federated PAT reports PAT,
federated M2M reports CLIENT_CREDENTIALS, etc.

Co-authored-by: Isaac
Build real TokenFederationProvider instances (instead of MagicMocks) so
attribute renames on external_provider break the test rather than passing
silently. Add a payload-serialization assertion confirming the federated
PAT case emits "auth_mech": "PAT" in the JSON event, and a None-inner-
provider edge case.

Co-authored-by: Isaac
Sets the mocked Session's auth_provider to a real TokenFederationProvider
wrapping AccessTokenAuthProvider, then asserts the captured
DriverConnectionParameters reports auth_mech=PAT. This catches regressions
in the wiring at client.py:383-384 (e.g., wrong provider passed to
TelemetryHelper) that the helper-only tests would miss.

Co-authored-by: Isaac
Copy link
Copy Markdown
Contributor

@msrathore-db msrathore-db left a comment

Choose a reason for hiding this comment

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

LGTM

@samikshya-db samikshya-db merged commit cbd6a88 into main Apr 28, 2026
33 of 34 checks passed
@samikshya-db samikshya-db deleted the telemetry-token-federation-auth branch April 28, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants