Skip to content

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

Open
fei (feiiiiii5) wants to merge 3 commits into
microsoft:mainfrom
feiiiiii5:fix/auth-config-fetch-failure
Open

FIX: surface auth config fetch failures instead of treating them as auth-disabled#2460
fei (feiiiiii5) wants to merge 3 commits into
microsoft:mainfrom
feiiiiii5:fix/auth-config-fetch-failure

Conversation

@feiiiiii5

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 — no login control, no error surface, no recovery path (#2441).

Fix

The two failure paths in fetchAuthConfig now throw with contextual messages instead of returning an empty config. The existing AuthProvider catch already renders its Authentication Error page for thrown errors, so it picks this up unchanged.

A 200 response carrying an empty config still means auth is disabled (local development), and that path is unchanged.

Test

  • Updated the two fetchAuthConfig tests that asserted the old swallow behaviour: non-2xx and network-error now expect rejects with the contextual messages.
  • Full msalConfig.test.ts + AuthProvider.test.tsx: 22/22 passing locally.
  • The existing "shows error when initialization fails with Error" provider test covers the consumer side of the new throw path.

Diff Scope

  • frontend/src/auth/msalConfig.ts: failure paths throw (+ comments explaining why)
  • frontend/src/auth/msalConfig.test.ts: two regression tests updated to the new contract

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