Skip to content

Fix prod failure page: disable Easy Auth on API and guard null game session#248

Merged
xenobiasoft merged 1 commit into
mainfrom
fix/prod-game-load-401-and-null-session
Apr 29, 2026
Merged

Fix prod failure page: disable Easy Auth on API and guard null game session#248
xenobiasoft merged 1 commit into
mainfrom
fix/prod-game-load-401-and-null-session

Conversation

@xenobiasoft
Copy link
Copy Markdown
Owner

What broke

The production Blazor app was showing a failure page whenever a user tried to load a saved game. Diagnosed via App Insights telemetry.

Root causes

1. Easy Auth blocking all Blazor → API calls (critical)

Azure Easy Auth (requireAuthentication: true) was enabled on the XenobiasoftSudokuApi-prod App Service — likely turned on manually via the Portal. The Blazor server makes server-to-server HTTP calls with no auth token, so every call to GET /api/players/{alias}/games/{id} returned 401 Unauthorized. LoadGameAsync treats any non-success response as a failure and throws, which navigates the user to /Error.

The React SWA is unaffected because it routes API calls through the SWA linked-backend proxy, which bypasses the App Service's Easy Auth.

Fix: Added authsettingsV2 Bicep resource to compute.bicep that explicitly disables Easy Auth on the API App Service, codifying the intent in IaC so it can't be accidentally re-enabled via the Portal.

2. NullReferenceException on navigation after failed load (medium)

The navigation handler (OnLocationChanging) is registered in InitializeGameAsync before LoadGameAsync is called. When the load fails and Blazor navigates to /Error, the handler fires and calls PauseSession() — but Game is null because the load never completed. Same risk exists in EndSession, ResumeSession, and StartNewSession.

Fix: Added if (Game == null) return; guards to all four session lifecycle methods in GameStatisticsManager.cs.

Test plan

  • Merge and confirm the next prod deployment applies the Bicep change (Easy Auth disabled)
  • Manually verify a saved game loads successfully in prod after deployment
  • Confirm no new exceptions appear in App Insights for XenobiasoftSudoku-prod
  • If you need an immediate fix before the next deploy: disable Easy Auth manually in the Azure Portal under XenobiasoftSudokuApi-prod → Authentication

🤖 Generated with Claude Code

… game session crash

- Disable Easy Auth on the API App Service via Bicep (requireAuthentication was
  blocking all Blazor server-to-server calls with 401, causing the failure page)
- Add null guards to all GameManager session lifecycle methods (PauseSession,
  EndSession, ResumeSession, StartNewSession) to prevent NullReferenceException
  when navigation fires before a game has successfully loaded

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-248.westus2.7.azurestaticapps.net

@xenobiasoft xenobiasoft merged commit fde3aef into main Apr 29, 2026
11 checks passed
@xenobiasoft xenobiasoft deleted the fix/prod-game-load-401-and-null-session branch April 29, 2026 00:18
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.

1 participant