[HSC-404] 전역 예외처리 구조 개선 및 인증/검증 응답 표준화#264
Conversation
Summary of ChangesHello, 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은 전역 예외 처리 구조를 개선하고 인증/검증 응답을 표준화하여 애플리케이션의 안정성과 보안을 강화하는 데 중점을 둡니다. 또한, 요청 검증을 강화하고 DB 제약 조건 충돌 처리 방식을 개선하여 개발 및 유지보수 효율성을 높입니다. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. Footnotes
|
🧪 Test Coverage Report (JaCoCo)
Package line spark (sample): 📦 Package coverage (worst 10)
🧨 Lowest coverage classes (worst 10)
🧩 Changed files coverage breakdown (69 files)
🔎 HTML 리포트: Actions → Artifacts → |
There was a problem hiding this comment.
Code Review
전반적으로 매우 훌륭한 리팩토링입니다. CustomException을 도메인별 예외 계층(DomainException, AuthException 등)으로 전환하고, ErrorCode를 인터페이스로 추상화하여 각 Bounded Context의 독립성을 높인 점이 인상적입니다. 또한, GlobalExceptionHandler를 Factory와 Mapper를 사용해 재구성하고 Spring Security 설정을 강화하여 코드의 안정성과 유지보수성을 크게 향상시켰습니다. 한 가지 아키텍처 관련 제안 사항을 리뷰 코멘트로 남겼으니 확인 부탁드립니다.
| import site.holliverse.customer.persistence.entity.Product; | ||
| import site.holliverse.customer.persistence.entity.Subscription; | ||
| import site.holliverse.customer.persistence.repository.ProductRepository; | ||
| import site.holliverse.customer.persistence.repository.SubscriptionRepository; |
There was a problem hiding this comment.
[위반 규칙]: 아키텍처 의존성 방향
[문제 이유]:
auth 모듈에 위치한 CustomerInitialPlanAssignmentUseCase가 customer 모듈의 퍼시스턴스 계층(ProductRepository, SubscriptionRepository 등)에 직접 의존하고 있습니다.
- 스타일 가이드(24-27행)에 명시된
admin과customer간의 의존성 규칙처럼,auth와 같은 핵심 도메인이 다른 비즈니스 도메인(customer)에 의존하는 것은 아키텍처적으로 바람직하지 않습니다. - 이는 모듈 간 결합도를 높이고, 향후
customer모듈이auth모듈에 의존해야 할 경우 순환 참조 문제를 야기할 수 있습니다.
InitialPlanAssignmentService 포트(Port)가 auth 도메인에 있는 것은 올바르지만, customer 도메인에 특화된 구현체(Adapter)는 customer 모듈 내에 위치하는 것이 의존성 역전 원칙(DIP)에 부합합니다.
[해결 제안]:
CustomerInitialPlanAssignmentUseCase.java 파일을 auth 모듈에서 customer 모듈로 이동하는 것을 제안합니다. 예를 들어 site.holliverse.customer.application.usecase.auth와 같은 패키지를 생성하여 관리하면, customer가 auth의 인터페이스에 의존하는 자연스러운 방향이 되어 모듈 간 경계가 더 명확해집니다.
References
- Customer와 Admin 모듈 간의 의존성 방향을 엄격히 제한하는 규칙입니다. 이 규칙의 원칙을 다른 모듈(auth, customer) 간의 관계에도 적용할 때, 현재 구현은
auth가customer에 의존하는 바람직하지 않은 방향을 가지고 있습니다. (link)
rettooo
left a comment
There was a problem hiding this comment.
인증 예외 처리와 도메인 별로 예외 처리로 일관되게 잘 해주셨네요 ! 수고하셨습니다!
… refactor/HSC-404 # Conflicts: # src/main/java/site/holliverse/admin/application/usecase/ChurnCouponIssueProcessor.java
…HSC-404 # Conflicts: # src/main/java/site/holliverse/admin/application/usecase/ChurnCouponIssueProcessor.java
📝작업 내용
전역 예외처리 구조를
CustomException중심에서DomainException중심 구조로 리팩토링했습니다.이번 PR에서 반영한 범위는 다음과 같습니다.
DomainException도입 및 도메인별 에러 enum 분리auth,customer,admin,infra단위 예외 클래스 및 에러코드 구조 적용@Valid적용 범위 확대ErrorCode + field구조로 매핑할 수 있도록ConstraintExceptionMapper도입GlobalExceptionHandler를 새 예외 구조 기준으로 재정리👀변경 사항
CustomException제거 후DomainException기반 구조로 전환AuthErrorCode,CustomerErrorCode,AdminErrorCode,InfraErrorCode추가AuthException,CustomerException,AdminException,InfraException추가SharedErrorCode,ErrorCategory,ApiErrorResponseFactory추가SecurityConfig에 인증/인가 규칙 적용,ApiAuthenticationEntryPoint,ApiAccessDeniedHandler추가CreateCounselDto,ChangeProductRequest,LogFeatureWebhookRequest,AnalysisResponseWebhookRequest등에 제약조건 추가@RequestBody기반 엔드포인트에@Valid적용 범위 확대ConstraintMapping,ConstraintExceptionMapper도입으로 DB constraint 예외를 구조화추가로 확인할 만한 정량 지표는 아래와 같습니다.
0/1212/126개0개@RequestBody+@Valid적용률6/1010/10CustomException사용 수430DomainException계열 사용 수0442/112/112/1111/11커밋은 아래와 같이 나누었습니다.
[HSC-404] refactor: 도메인 예외 구조 도입[HSC-404] feat: 인증 예외 처리 중앙화[HSC-404] feat: 요청 검증과 DB 충돌 응답 개선🎫 Jira Ticket
#️⃣관련 이슈
참고 자료
https://one-year-gap.github.io/docs/2026/03/22/%EC%97%90%EC%99%B8%EC%B2%98%EB%A6%AC-%EA%B3%A0%EB%8F%84%ED%99%94/