Skip to content

Comments

[배포] DataIntegrityViolationException 처리#315

Merged
wlgns12370 merged 2 commits intoprodfrom
develop
Aug 11, 2025
Merged

[배포] DataIntegrityViolationException 처리#315
wlgns12370 merged 2 commits intoprodfrom
develop

Conversation

@wlgns12370
Copy link
Contributor

✨ 구현한 기능

  • DataIntegrityViolationException 처리

📢 논의하고 싶은 내용

  • x

🎸 기타

  • x

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @wlgns12370, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 주로 OAuth 사용자 처리 중 DataIntegrityViolationException에 대한 오류 처리를 개선하는 데 중점을 둡니다. 또한, DepositStatus 열거형을 문자열로 저장하기 위한 데이터베이스 스키마 마이그레이션 및 해당 엔티티 업데이트, 그리고 사용자 테스트 픽스처의 사소한 정리를 포함합니다.

Highlights

  • 오류 처리 개선: OAuthUserPersistenceProcessor에서 DataIntegrityViolationException을 처리하고 USER_ALREADY_EXISTS 오류 코드를 가진 CustomRuntimeException을 발생시키도록 구현했습니다.
  • 데이터베이스 스키마 마이그레이션: virtual_account_log 테이블의 deposit_status 컬럼을 VARCHAR 타입으로 변경하는 새로운 Flyway 마이그레이션 스크립트를 추가했습니다.
  • 엔티티 업데이트: VirtualAccountLogJpaEntity의 depositStatus 필드에 @Enumerated(EnumType.STRING) 어노테이션을 적용하여 열거형 값을 문자열로 영속화하도록 했습니다.
  • 테스트 픽스처 정리: 사용자 테스트 픽스처에서 더 이상 필요 없는 agreedToTermsOfService 및 agreedToPrivacyPolicy 필드를 제거했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@wlgns12370 wlgns12370 merged commit 231fdd5 into prod Aug 11, 2025
5 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

안녕하세요. DataIntegrityViolationException 처리를 추가하고 deposit_status 필드 타입을 개선하는 PR을 리뷰했습니다. OAuth 사용자 생성 시 발생할 수 있는 경쟁 상태(race condition)를 처리한 점과, enum 타입을 데이터베이스에 문자열로 저장하도록 변경한 점은 좋은 개선입니다. 다만, 리뷰 과정에서 몇 가지 잠재적인 위험 요소를 발견했습니다. 특히 데이터베이스 마이그레이션 스크립트는 데이터 손실을 유발할 수 있어 주의가 필요합니다. 자세한 내용은 아래 주석을 확인해주세요.

Comment on lines +1 to +5
ALTER TABLE virtual_account_log
DROP COLUMN deposit_status;

ALTER TABLE virtual_account_log
ADD deposit_status VARCHAR(255) NULL; No newline at end of file

Choose a reason for hiding this comment

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

critical

현재 마이그레이션 스크립트는 deposit_status 컬럼을 삭제 후 재생성하므로, 기존의 모든 데이터가 손실될 위험이 있습니다. 또한, 컬럼이 NULL을 허용하도록 재생성되어 기존 행들의 해당 컬럼 값은 NULL이 됩니다. VirtualAccountLogJpaEntity에서는 이 필드가 DepositStatus.WAITING으로 초기화되므로, NULL 값은 NullPointerException 등 예기치 않은 동작을 유발할 수 있습니다.

데이터 손실을 방지하고 데이터 무결성을 지키기 위해, ALTER COLUMN을 사용해 컬럼 타입을 변경하거나, 데이터를 임시 컬럼으로 백업 후 복원하는 방식으로 마이그레이션 스크립트를 수정하는 것을 강력히 권장합니다.

return userRepository.save(newUser);
});
try {
return userRepository.findByPhoneNumber(info.phoneNumber())

Choose a reason for hiding this comment

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

high

전화번호로 기존 사용자를 찾는 로직에 버그가 있을 수 있습니다. UserJpaEntity에는 PhoneNumberUtil.formatPhoneNumber()를 통해 'U' 접두사가 붙은 전화번호가 저장됩니다. 하지만 현재 코드는 접두사 없는 원본 전화번호로 조회하고 있어, 항상 기존 사용자를 찾지 못하고 신규 사용자 생성을 시도하게 됩니다. 이로 인해 의도치 않게 DataIntegrityViolationException이 발생하고 예외 처리 로직에 의존하게 될 수 있습니다.

findByPhoneNumber 호출 전에 전화번호를 포맷팅하여 이 문제를 해결하는 것이 좋습니다.

Suggested change
return userRepository.findByPhoneNumber(info.phoneNumber())
return userRepository.findByPhoneNumber(PhoneNumberUtil.formatPhoneNumber(info.phoneNumber()))

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