[hotfix] #188 - 캘린더 연동 상태에서 회원 탈퇴 시 500 에러#192
Merged
Conversation
Walkthrough사용자별 리보케이션 토큰 선택을 저장소 쿼리로 이동하고, AuthService가 반환된 토큰을 사용해 캘린더 리보케이션 아웃박스를 생성하도록 변경했습니다. Changes캘린더 연결 리보케이션
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/main/java/com/Timo/Timo/domain/calendar/entity/CalendarRevocationOutbox.javasrc/main/java/com/Timo/Timo/domain/calendar/repository/CalendarConnectionRepository.javasrc/main/java/com/Timo/Timo/global/auth/service/AuthService.java
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.
관련 이슈 🛠
작업 내용 요약 ✏️
캘린더 연동 상태에서 회원 탈퇴 시 500 에러가 발생하던 문제를 수정합니다.
주요 변경 사항 🛠️
CalendarConnectionRepository에findTokenToRevokeByUserId(userId)쿼리 메서드 추가AuthService.revokeCalendarConnectionIfExists()가CalendarConnection엔티티 대신 위 쿼리 메서드를 사용하도록 변경트러블 슈팅 ⚽️
캘린더 연동 상태에서만 회원 탈퇴가 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참조가 영속성 컨텍스트에 로드되지 않도록 수정했습니다.테스트 결과 📄
스크린샷 📷
리뷰 요구사항 📢
📎 참고 자료 (선택)
Summary by CodeRabbit