Skip to content

Conversation

Copy link

Copilot AI commented Oct 1, 2025

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}/actions endpoint was missing a check for game.isEnded(). While it correctly checked for transition steps with game.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:

// Before
if (game.isTransitionStep()) {
  throw new ServerError(errors.DURING_TRANSITION_STEP);
}

// After  
if (game.isTransitionStep()) {
  throw new ServerError(errors.DURING_TRANSITION_STEP);
}

if (game.isEnded()) {
  throw new ServerError(errors.GAME_ENDED);
}

Changes

  • Added new error code: GAME_ENDED (107) with message "game has ended"
  • Enhanced validation: Actions sent to ended games now return HTTP 400 with the appropriate error
  • Maintained consistency: Follows the same pattern used in miyakonojo and tomakomai implementations
  • Added test coverage: Created comprehensive test to verify the fix works correctly

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.land
    • Triggering command: curl -s REDACTED (dns block)
    • Triggering command: 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

This section details on the original issue you should resolve

<issue_title>ゲーム終了した後も行動送信が普通にできてしまう</issue_title>
<issue_description>### バグの説明

ゲーム終了した後も特にエラーメッセージはなく行動を受け付けてしまっていそうです。(ゲームは進んでいないので特に進行には問題なさそう)

再現手順

ゲーム終了したあとに PATCH /v1/matches/{gameId}/actions を叩く

期待される動作

何かエラーレスポンスになるといいのかも

スクリーンショット

No response

OS

Windows

ブラウザ

No response

機種(スマートフォンの場合)

No response

その他

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #266

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: kamekyame <47011206+kamekyame@users.noreply.github.com>
Copilot AI changed the title [WIP] ゲーム終了した後も行動送信が普通にできてしまう Fix: Prevent actions from being sent after game ends in v1 API Oct 1, 2025
Copilot AI requested a review from kamekyame October 1, 2025 13:47
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.

ゲーム終了した後も行動送信が普通にできてしまう

2 participants