Fix: Prevent actions from being sent after game ends in v1 API #267
+134
−1
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.
Problem
The v1 API was incorrectly allowing actions to be sent after a game has ended without returning any error. This was inconsistent with the behavior in the miyakonojo and tomakomai API versions, which properly reject such requests.
Root Cause
The
PATCH /v1/matches/{gameId}/actionsendpoint was missing a check forgame.isEnded(). While it correctly checked for transition steps withgame.isTransitionStep(), it did not validate whether the game had already finished.Solution
Added the missing
game.isEnded()check to the v1 actions endpoint, bringing it in line with other API versions:Changes
GAME_ENDED(107) with message "game has ended"Behavior
Before: Actions sent after game end were silently accepted (no error returned)
After: Actions sent after game end return HTTP 400 with error code 107 and message "game has ended"
This fix ensures that the v1 API properly validates game state and provides clear feedback when attempting invalid operations.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.deno.landcurl -s REDACTED(dns block)curl --fail --location --progress-bar --output /home/REDACTED/.deno/bin/deno.zip REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.