Skip to content

Exclude caller SDK telemetry from access token cache keys - #6074

Merged
Bogdan Gavril (bgavrilMS) merged 2 commits into
mainfrom
bgavril/caller-sdk-cache-key
Jun 18, 2026
Merged

Bogdan Gavril (bgavrilMS) merged 2 commits into
mainfrom
bgavril/caller-sdk-cache-key

Conversation

@bgavrilMS

Copy link
Copy Markdown
Member

Summary

  • Prevent caller-sdk-id and caller-sdk-ver from remaining in cache key components after caller SDK telemetry is extracted.
  • Preserve other explicitly included extra query parameters in AT cache key components.
  • Add regression coverage proving caller SDK telemetry does not fragment the app AT cache even when IncludeInCacheKey=true.

Fixes #6073

Testing

  • dotnet test tests\Microsoft.Identity.Test.Unit\Microsoft.Identity.Test.Unit.csproj --framework net8.0 --filter "FullyQualifiedName~CallerSdkDetails_AreNeverIncludedInCacheKeyComponentsAsync" --no-restore --verbosity minimal
  • dotnet test tests\Microsoft.Identity.Test.Unit\Microsoft.Identity.Test.Unit.csproj --framework net8.0 --filter "FullyQualifiedName~HttpTelemetryTests" --no-restore --verbosity minimal

Note: a multi-target run without --framework net8.0 also attempted net48 and hit an existing MSTest adapter dependency load error for System.Memory, Version=4.0.1.2 before net8.0 passed.

Caller SDK metadata is telemetry-only and should not partition access token cache entries even when supplied through WithExtraQueryParameters with IncludeInCacheKey=true.

Fixes #6073

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures the telemetry-only extra query parameters caller-sdk-id and caller-sdk-ver never influence access token cache key computation (even when callers explicitly request IncludeInCacheKey=true), preventing avoidable app token cache fragmentation.

Changes:

  • Remove caller-sdk-id / caller-sdk-ver from AuthenticationRequestParameters.CacheKeyComponents during request initialization.
  • Add a regression unit test proving cache key components retain only non-telemetry entries when IncludeInCacheKey=true.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/client/Microsoft.Identity.Client/Internal/Requests/RequestBase.cs Strips caller SDK telemetry keys from request cache key components before cache lookup/storage.
tests/Microsoft.Identity.Test.Unit/TelemetryTests/HttpTelemetryTests.cs Adds regression coverage ensuring caller SDK telemetry does not partition the app access token cache.

Assert cache key components after each AcquireTokenForClient call so both initial storage and subsequent cache lookup preserve caller SDK telemetry exclusion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bgavrilMS
Bogdan Gavril (bgavrilMS) enabled auto-merge (squash) June 18, 2026 14:17
@bgavrilMS
Bogdan Gavril (bgavrilMS) merged commit fe25195 into main Jun 18, 2026
15 checks passed
@bgavrilMS
Bogdan Gavril (bgavrilMS) deleted the bgavril/caller-sdk-cache-key branch June 18, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] caller-sdk telemetry parameters must not affect access token cache keys

4 participants