fix: navigating non-player to spectate - #1341
Merged
itsalaidbacklife merged 7 commits intoAug 18, 2026
Merged
Conversation
The non-player check dereferenced `response.game.players` unconditionally. On a 401, `requestGameState` sets `mustReauthenticate` and resolves with a message string rather than a game state, so that dereference threw a TypeError. The guard's own catch turned it into a redirect to Home, whose `mustBeAuthenticated` guard then bounced to /login -- losing the game the player was in. Only run the check when the response actually carries a game state, so a lost session falls through to GameView and its ReauthenticateDialog. This also covers the response shape get-game returns for a game with no gameStates, which likewise has no `game` key. Adds the regression test issue cuttle-cards#1319 never got, mirroring the existing "Prevents spectating your own game while it's ongoing" case. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Resolving `jwres.body.message` gave callers a plain string where they expect a game state, which is what let the non-player spectate check throw a TypeError on a lost session. No caller consumed that string, so resolve null instead and make the "no game state" contract explicit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
itsalaidbacklife
approved these changes
Aug 18, 2026
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.
Issue number #1319
Relevant issue number
Please check the following
Please describe additional details for testing this change