Skip to content

(v5) bugfix get native account#8105

Open
lalimasharda wants to merge 14 commits intodevfrom
v5_bugfix_getNativeAccount
Open

(v5) bugfix get native account#8105
lalimasharda wants to merge 14 commits intodevfrom
v5_bugfix_getNativeAccount

Conversation

@lalimasharda
Copy link
Contributor

@lalimasharda lalimasharda commented Oct 17, 2025

v5 PR for the getNativeAccountId bug fix (#7960)

@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?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Nov 3, 2025
@lalimasharda lalimasharda marked this pull request as draft March 12, 2026 17:04
@lalimasharda lalimasharda marked this pull request as ready for review March 12, 2026 17:31
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Mar 12, 2026
@lalimasharda
Copy link
Contributor Author

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

Yes. This change is already present in v4.

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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Copy link
Contributor

Copilot AI commented Mar 12, 2026

@lalimasharda I've opened a new pull request, #8420, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Mar 12, 2026

@lalimasharda I've opened a new pull request, #8421, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 12, 2026

@lalimasharda I've opened a new pull request, #8422, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

4 participants