Skip to content

[hotfix] #188 - 캘린더 연동 상태에서 회원 탈퇴 시 500 에러#192

Merged
Jy000n merged 3 commits into
developfrom
hotfix/#188-withdraw-error
Jul 16, 2026
Merged

[hotfix] #188 - 캘린더 연동 상태에서 회원 탈퇴 시 500 에러#192
Jy000n merged 3 commits into
developfrom
hotfix/#188-withdraw-error

Conversation

@Jy000n

@Jy000n Jy000n commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

관련 이슈 🛠

작업 내용 요약 ✏️

캘린더 연동 상태에서 회원 탈퇴 시 500 에러가 발생하던 문제를 수정합니다.

주요 변경 사항 🛠️

  • [Calendar] CalendarConnectionRepositoryfindTokenToRevokeByUserId(userId) 쿼리 메서드 추가
    • 엔티티 전체가 아닌, revoke에 필요한 토큰 문자열만 JPQL로 직접 조회
  • [Auth] AuthService.revokeCalendarConnectionIfExists()CalendarConnection 엔티티 대신 위 쿼리 메서드를 사용하도록 변경

트러블 슈팅 ⚽️

캘린더 연동 상태에서만 회원 탈퇴가 500으로 실패하던 문제

  • 캘린더 연동을 하지 않은 사용자는 탈퇴가 정상(200) 처리되는데, 연동한 사용자만 탈퇴 시 500이 발생하는 것을 확인했습니다.
  • 원인은 revokeCalendarConnectionIfExists()에서 calendarConnectionRepository.findByUserId(userId)CalendarConnection 엔티티를 조회하고 있었기 때문입니다. 이 엔티티는 User를 참조하는 @OneToOne 연관관계를 갖고 있는데, 조회하는 순간 영속성 컨텍스트에 CalendarConnection이 managed 상태로 등록되고, 그 안의 user 필드가 곧 삭제될 User를 계속 참조하게 됩니다.
  • users 테이블에는 ON DELETE CASCADE 제약이 걸려 있어 DB 레벨에서는 사용자 삭제 시 연동 정보도 함께 삭제되지만, 이는 순수 DB 레벨 규칙이라 Hibernate 영속성 컨텍스트는 이 사실을 알지 못합니다. 그 결과 트랜잭션 flush 시점에 "삭제 예정인 User를 여전히 참조하는 영속 인스턴스가 있다"고 판단해 TransientObjectException(500)을 던지고 있었습니다.
  • CalendarConnection 엔티티 자체를 조회하지 않고, revoke에 필요한 토큰 문자열만 JPQL로 직접 조회하도록 변경하여 User 참조가 영속성 컨텍스트에 로드되지 않도록 수정했습니다.

테스트 결과 📄

스크린샷 📷

image

리뷰 요구사항 📢

image

📎 참고 자료 (선택)

Summary by CodeRabbit

  • 버그 수정
    • 캘린더 연결 해제 시 리보크에 사용할 토큰을 일관되게 선택하도록 개선했습니다.
    • 리프레시 토큰이 없을 경우 액세스 토큰을 사용하도록 처리했습니다.
    • 선택된 토큰이 캘린더 연결 해제 요청에 정확히 기록됩니다.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

사용자별 리보케이션 토큰 선택을 저장소 쿼리로 이동하고, AuthService가 반환된 토큰을 사용해 캘린더 리보케이션 아웃박스를 생성하도록 변경했습니다.

Changes

캘린더 연결 리보케이션

Layer / File(s) Summary
리보케이션 토큰 조회 계약
src/main/java/com/Timo/Timo/domain/calendar/repository/CalendarConnectionRepository.java
사용자 ID로 리프레시 토큰을 우선 조회하고, 없으면 액세스 토큰을 반환하는 Optional<String> 메서드와 쿼리를 추가했습니다.
리보케이션 아웃박스 기록
src/main/java/com/Timo/Timo/global/auth/service/AuthService.java, src/main/java/com/Timo/Timo/domain/calendar/entity/CalendarRevocationOutbox.java
AuthService가 새 저장소 메서드의 토큰으로 CalendarRevocationOutbox를 저장하도록 변경했으며, 엔티티 종료부를 갱신했습니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Team-Timo/Timo-Server#44: AuthService의 캘린더 리보케이션 토큰 선택 로직과 직접 관련된 변경입니다.

Suggested reviewers: laura-jung, aneykrap

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed 회원 탈퇴 시 500 에러를 막기 위해 토큰 조회 쿼리 추가와 서비스 로직 변경이 이루어져 이슈 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 핵심 수정 외에는 기능 변경이 없고, 나머지 변경도 종료 중괄호/서식 수준입니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 캘린더 연동 상태에서 회원 탈퇴 시 발생하던 500 오류 수정이라는 변경의 핵심을 정확히 요약합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/#188-withdraw-error

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/Timo/Timo/domain/calendar/repository/CalendarConnectionRepository.java`:
- Around line 4-19: Replace the incorrect Param import used by
CalendarConnectionRepository with
org.springframework.data.repository.query.Param, leaving
findTokenToRevokeByUserId and its query unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a3bef30a-d1d1-4039-b622-6871248d2765

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7fee4 and 1408c1f.

📒 Files selected for processing (3)
  • src/main/java/com/Timo/Timo/domain/calendar/entity/CalendarRevocationOutbox.java
  • src/main/java/com/Timo/Timo/domain/calendar/repository/CalendarConnectionRepository.java
  • src/main/java/com/Timo/Timo/global/auth/service/AuthService.java

@laura-jung laura-jung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어푸입니다아 수고했으요

@aneykrap aneykrap left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엔티티에 @onDelete(CASCADE)를 추가하면 재생성하는 migration도 같이 필요한건가용?

@github-actions github-actions Bot added the slack-approval-notified Slack 승인 완료 알림 중복 방지용 라벨 label Jul 16, 2026
@Jy000n Jy000n merged commit a565439 into develop Jul 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌸 자윤 🚨 hotfix slack-approval-notified Slack 승인 완료 알림 중복 방지용 라벨

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[hotfix] 회원 탈퇴 에러

3 participants