Skip to content

fix: msal-react passes undefined to ssoSilent when no request provided#8520

Open
lalimasharda wants to merge 5 commits intodevfrom
bugfix/msal-react-ssoSilent
Open

fix: msal-react passes undefined to ssoSilent when no request provided#8520
lalimasharda wants to merge 5 commits intodevfrom
bugfix/msal-react-ssoSilent

Conversation

@lalimasharda
Copy link
Copy Markdown
Contributor

@lalimasharda lalimasharda commented Apr 8, 2026

When useMsalAuthentication is used with InteractionType.Silent and no authenticationRequest, instance.ssoSilent(undefined) was called, causing the silent flow to fail (issue #8382).

Changes

  • useMsalAuthentication: Fall back to {} instead of undefined when no loginRequest is available, so ssoSilent always receives a valid request object
  • MsalAuthenticationTemplate.spec.tsx: Updated test expectation to match the new {} fallback
  • StandardController: Removed redundant prompt assignment from validRequest construction (already covered by the spread)
  • hooks.md: Updated Silent interaction type note — request is now optional (empty object used as fallback), though providing loginHint, sid, or account is still strongly recommended
// Before
return instance.ssoSilent(loginRequest as SsoSilentRequest); // loginRequest could be undefined

// After
return instance.ssoSilent(loginRequest ? (loginRequest as SsoSilentRequest) : {});

Copilot AI review requested due to automatic review settings April 8, 2026 20:41
@lalimasharda lalimasharda requested a review from a team as a code owner April 8, 2026 20:41
Copy link
Copy Markdown
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 MSAL React where InteractionType.Silent could end up calling instance.ssoSilent(undefined) when no authenticationRequest is provided, preventing the silent authentication flow from starting (issue #8382). It also includes a small cleanup in MSAL Browser around ssoSilent request construction.

Changes:

  • Update useMsalAuthentication to pass {} (instead of undefined) to ssoSilent when no request is provided.
  • Update the MsalAuthenticationTemplate test to expect an empty object for the ssoSilent request.
  • Remove redundant prompt assignment/comment in msal-browser StandardController.ssoSilent request normalization.

Reviewed changes

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

File Description
lib/msal-react/src/hooks/useMsalAuthentication.ts Ensures ssoSilent is always invoked with a defined request object ({} fallback).
lib/msal-react/test/components/MsalAuthenticationTemplate.spec.tsx Aligns test expectations with the new {} fallback behavior.
lib/msal-browser/src/controllers/StandardController.ts Removes redundant prompt property assignment when building validRequest.

Copilot AI changed the title fix msal-react passing in undefined ssoSilent request fix: msal-react passes undefined to ssoSilent when no request provided Apr 8, 2026
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