Skip to content

Conversation

@lalimasharda
Copy link
Contributor

v5 PR for the getNativeAccountId bug fix (#7960)

  • Fall back to getting the native account id of the active account if no loginhint or sid is provided.

@lalimasharda lalimasharda requested a review from a team as a code owner October 17, 2025 19:41
Copilot AI review requested due to automatic review settings October 17, 2025 19:41
Copy link
Contributor

Copilot AI left a comment

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 fixes a bug in the native account retrieval logic by adding validation for empty or invalid account filters. When no login hint or SID is provided, the code now properly falls back to using the active account's native account ID instead of attempting to filter with invalid criteria.

Key changes:

  • Added validation in CacheManager.getAccountInfoFilteredBy to detect and handle empty/invalid account filters
  • Removed redundant filter validation from AccountManager.getAccount since it's now handled at the cache layer
  • Added test coverage for the new validation logic

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/msal-common/src/cache/CacheManager.ts Added validation to return null and log a warning when account filter is empty or contains only falsy values
lib/msal-common/test/cache/CacheManager.spec.ts Added test case verifying null is returned when filter has empty string values
lib/msal-browser/src/cache/AccountManager.ts Removed duplicate empty filter check and simplified logging
lib/msal-browser/test/cache/BrowserCacheManager.spec.ts Added test case verifying null is returned when filter has undefined values

@peterzenz
Copy link
Contributor

This looks like it changes the behavior of the API, is this intended?

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.

3 participants