Skip to content

fix: 게임 빌드 웹훅을 업로드 중인 빌드에만 반영한다 - #152

Merged
ff1451 merged 1 commit into
mainfrom
fix/game-build-webhook-state
Oct 18, 2026
Merged

ff1451 merged 1 commit into
mainfrom
fix/game-build-webhook-state

Conversation

@ff1451

@ff1451 ff1451 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

요약

홈페이지 서버의 완료 웹훅(POST /v1/games/builds/{id}/webhook)이 빌드의 현재 상태를 보지 않고 결과를 덮어썼다. 그래서:

  • 다시 보내거나 늦게 도착한 ACTIVE 웹훅이 보관(ARCHIVED)된 옛 빌드를 다시 활성화하고, 그 과정에서 현재 활성 빌드를 보관으로 내렸다.
  • 늦게 도착한 FAILED 웹훅이 활성 빌드를 FAILED로 바꿔 게임에 활성 빌드가 사라질 수 있었다.
  • 업로드 토큰도 받지 않은 PENDING 빌드가 활성화될 수 있었다.

변경

  • 상태 전이 규칙을 엔티티(GameBuild.applyActive/markFailed)에 둔다.
    • ACTIVE·FAILED 반영은 업로드 중(PROCESSING)인 빌드에서만 한다. 그 밖의 상태면 409 GAME_BUILD_INVALID_STATE(이미 있던 "이 상태의 빌드에는 처리할 수 없습니다").
    • 같은 결과의 재전송(ACTIVE→ACTIVE, FAILED→FAILED)은 재시도로 보고 아무것도 바꾸지 않은 채 204.
    • 업로드 토큰 발급(PENDING/PROCESSING/FAILED → PROCESSING)은 그대로라, 실패한 빌드는 지금처럼 토큰을 다시 받아 재업로드할 수 있다.
  • 같은 빌드에 대한 동시 웹훅이 엇갈리지 않게 findByIdForUpdate로 빌드 행을 잠그고 읽는다.

남은 위험

"게임당 활성 빌드 1개"는 여전히 애플리케이션이 지킨다. 한 게임의 서로 다른 두 빌드가 동시에 활성화되면 둘 다 ACTIVE로 남을 수 있다(관리자가 빌드를 하나씩 올리므로 현실적으로 드묾). 정석은 game_build (game_id) WHERE status = 'ACTIVE' 부분 유니크 인덱스인데, 운영 데이터에 이미 중복이 있으면 마이그레이션이 실패해 앱이 뜨지 않으므로 운영 DB를 확인할 수 있을 때 따로 넣는다.

테스트

AdminGameBuildIntegrationTest에 4건 추가 — 모두 수정 전 코드에서 실패함을 확인했다.

  • 보관된 옛 빌드의 ACTIVE 재전송 → 409, 현재 활성 빌드 유지 (이전: 204, 옛 빌드 활성화)
  • 활성 빌드의 늦은 FAILED → 409, 활성 유지 (이전: 204)
  • 같은 ACTIVE 재전송 → 204, 다른 URL로 덮어쓰지 않음 (이전: 덮어씀)
  • 토큰 없는 PENDING 빌드의 ACTIVE → 409 (이전: 204)

로컬 전체 ./gradlew test: 544건 중 543 통과, 1 스킵.

완료 웹훅이 빌드의 현재 상태를 보지 않아, 다시 보내거나 늦게 도착한 웹훅이
보관된 옛 빌드를 다시 활성화하거나(현재 빌드는 보관됨), 활성 빌드를 FAILED로 내릴 수 있었다.

- 상태 전이 규칙을 GameBuild에 둔다: ACTIVE·FAILED 반영은 PROCESSING에서만, 아니면 409.
  같은 결과의 재전송(ACTIVE->ACTIVE, FAILED->FAILED)은 아무것도 바꾸지 않고 204.
- 같은 빌드에 대한 동시 웹훅이 엇갈리지 않게 빌드 행을 잠그고 읽는다.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61047cb6-e76c-4798-b01a-39d5331eee6d
📥 Commits

Reviewing files that changed from the base of the PR and between bba378e and 38df7ee.

📒 Files selected for processing: 4
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/game/model/GameBuild.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/game/repository/GameBuildRepository.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/game/service/GameBuildWebhookService.java
  • src/test/java/com/bcsdlab/bcsdinternalapiv2/game/AdminGameBuildIntegrationTest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ff1451
ff1451 merged commit da4a713 into main Oct 18, 2026
2 checks passed
@ff1451
ff1451 deleted the fix/game-build-webhook-state branch October 18, 2026 13:51
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