Fix prod failure page: disable Easy Auth on API and guard null game session#248
Merged
Merged
Conversation
… 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>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://gray-bush-02024e71e-248.westus2.7.azurestaticapps.net |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theXenobiasoftSudokuApi-prodApp Service — likely turned on manually via the Portal. The Blazor server makes server-to-server HTTP calls with no auth token, so every call toGET /api/players/{alias}/games/{id}returned 401 Unauthorized.LoadGameAsynctreats 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
authsettingsV2Bicep resource tocompute.bicepthat 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 inInitializeGameAsyncbeforeLoadGameAsyncis called. When the load fails and Blazor navigates to/Error, the handler fires and callsPauseSession()— butGameis null because the load never completed. Same risk exists inEndSession,ResumeSession, andStartNewSession.Fix: Added
if (Game == null) return;guards to all four session lifecycle methods inGameStatisticsManager.cs.Test plan
XenobiasoftSudoku-prodXenobiasoftSudokuApi-prod → Authentication🤖 Generated with Claude Code