Skip to content

FIX: surface auth config fetch failures instead of treating them as auth-disabled - #2460

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
feiiiiii5:fix/auth-config-fetch-failure
Aug 23, 2026
Merged

FIX: surface auth config fetch failures instead of treating them as auth-disabled#2460
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
feiiiiii5:fix/auth-config-fetch-failure

Conversation

@feiiiiii5

@feiiiiii5 fei (feiiiiii5) commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Root Cause

fetchAuthConfig() in frontend/src/auth/msalConfig.ts collapsed both non-2xx responses and network errors into an empty AuthConfig. AuthProvider reads an empty config as "authentication disabled", so a transient failure of /api/auth/config rendered the normal app shell while protected APIs returned raw Missing or invalid Authorization header text. There was no login control, error surface, or recovery path (#2441).

Fix

The two failure paths in fetchAuthConfig now throw with contextual messages instead of returning an empty config. Wrapped network errors preserve the original error as their cause.

AuthProvider renders its Authentication Error page for these failures and now tells users to reload the page to try again. A 200 response carrying an empty config still means auth is disabled for local development, and that path is unchanged.

Test

  • Updated the two fetchAuthConfig tests that asserted the old swallow behavior. Non-2xx and network errors now reject with contextual messages, and the network test verifies the original error is preserved as the cause.
  • Updated the AuthProvider error-state test to verify the reload guidance.
  • msalConfig.test.ts and AuthProvider.test.tsx: 22/22 passing locally.
  • Verified in a browser that a failed config request renders the Authentication Error page with reload guidance, and that reloading recovers after the backend becomes available.

Diff Scope

  • frontend/src/auth/msalConfig.ts: surface config fetch failures and preserve network error context
  • frontend/src/auth/msalConfig.test.ts: cover HTTP failures, network failures, and error cause preservation
  • frontend/src/auth/AuthProvider.tsx: add reload guidance to the authentication error state
  • frontend/src/auth/AuthProvider.test.tsx: verify the reload guidance

Development was AI-assisted with human review of all changes.

Fixes #2441

@romanlutz Roman Lutz (romanlutz) changed the title fix(frontend): surface auth config fetch failures instead of treating them as auth-disabled FIX: surface auth config fetch failures instead of treating them as auth-disabled Aug 22, 2026
fei (feiiiiii5) and others added 2 commits August 22, 2026 06:13
… them as auth-disabled

fetchAuthConfig collapsed both non-2xx responses and network errors into
an empty AuthConfig, which AuthProvider interpreted as "authentication
disabled". When /api/auth/config failed transiently while protected APIs
returned 401, the app rendered the normal shell with raw "Missing or
invalid Authorization header" text and no login control or error surface
(microsoft#2441).

The two failure paths now throw so the existing AuthProvider catch
renders its Authentication Error page. A 200 response with an empty
config still means auth is disabled (local dev), unchanged.

Fixes microsoft#2441

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) force-pushed the fix/auth-config-fetch-failure branch from 0458e23 to a6519ab Compare August 22, 2026 13:15
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Aug 23, 2026
Merged via the queue into microsoft:main with commit 7307d94 Aug 23, 2026
47 checks passed
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.

Authentication-config failure leaves the frontend in an authorization dead end

3 participants