-
Notifications
You must be signed in to change notification settings - Fork 3
fix : 회원 정보 수정 API Swagger 및 S3 이미지 삭제 버그 수정 #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- swagger 페이지에서 서버(배포 서버와 로컬 서버)를 선택할 수 있도록 함
- 삭제할 버킷의 이미지의 변수가 새로운 이미지 URL을 참조하고 있었음 - 인코딩 문제 해결
📋 개요이 PR은 사용자 프로필 이미지 삭제 로직을 수정하고, S3 파일명 디코딩을 추가하며, Swagger 설정에 로컬 서버를 추가하고, UserController 문서화를 개선합니다. 🚶 순서도사용자 프로필 이미지 및 S3 객체 삭제 로직에 대한 수정 사항입니다. 변경 사항은 주로 버그 수정 및 문서화 개선이며, 새로운 제어 흐름을 도입하지 않으므로 시퀀스 다이어그램은 생략합니다. 📝 변경 사항
📊 예상 코드 리뷰 소요 시간🎯 3 (보통) | ⏱️ ~20분 세부 검토 항목:
🔗 관련 PR
🏷️ 제안 라벨
👥 제안 검토자
🐰 축하 시
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java (2)
83-86: 빈 문자열 검증 추가 권장URL 디코딩 로직은 올바르지만,
fileName이 빈 문자열일 경우를 처리하지 않습니다. PR 요약에서 언급된 대로 UserService는StringUtils.hasText()로 검증하지만, S3Uploader 자체는 빈 문자열에 대한 방어 로직이 없습니다.다음 diff를 적용하여 빈 문자열 검증을 추가하세요:
+ if (!StringUtils.hasText(fileName)) { + log.warn("S3 삭제 시도: 빈 파일명, URL: {}", fileUrl); + return; + } + String decodedFileName = URLDecoder.decode(fileName, StandardCharsets.UTF_8); amazonS3.deleteObject(bucket, decodedFileName);파일 상단에 import 추가:
+import org.springframework.util.StringUtils;
87-87: 로그 일관성 개선 제안삭제 작업은
decodedFileName을 사용하지만 로그는 원본fileName을 출력합니다. 디버깅 시 혼란을 줄 수 있습니다.로그에 디코딩된 파일명을 출력하도록 변경을 고려하세요:
- log.info("S3에서 이미지 삭제 완료: {}", fileName); + log.info("S3에서 이미지 삭제 완료: {}", decodedFileName);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java(2 hunks)src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java(2 hunks)src/main/java/org/ezcode/codetest/infrastructure/swagger/config/SwaggerConfig.java(1 hunks)src/main/java/org/ezcode/codetest/presentation/usermanagement/UserController.java(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
src/main/java/org/ezcode/codetest/infrastructure/swagger/config/SwaggerConfig.java (1)
19-23: 로컬 개발 서버 추가 승인Swagger UI에서 로컬 환경 테스트를 위한 서버 추가가 적절합니다. 개발 경험을 개선하면서 프로덕션 환경에는 영향을 주지 않습니다.
src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java (1)
105-114: 중요한 버그 수정 확인프로필 이미지 삭제 로직이 올바르게 수정되었습니다:
oldImageUrl을 엔티티 업데이트 전에 백업 (line 107)- 엔티티를 새 이미지 URL로 업데이트 (line 109)
- 백업된
oldImageUrl을 사용하여 S3에서 삭제 (line 112)
StringUtils.hasText()사용으로 null뿐만 아니라 빈 문자열도 처리하여 더욱 견고합니다. 이전에는 업데이트 후 새 이미지가 삭제되는 버그가 있었는데, 이제 정확히 수정되었습니다.src/main/java/org/ezcode/codetest/presentation/usermanagement/UserController.java (1)
50-60: Swagger Content-Type 문제 해결 확인
@RequestBody어노테이션에@Encoding을 추가하여 Swagger UI가request파트를application/json으로 전송하도록 강제한 것이 적절합니다. 이전에 발생하던HttpMediaTypeNotSupportedException오류가 해결됩니다.코드 내 한글 주석으로 핵심 수정 사항을 명확히 설명한 점도 좋습니다.
작업 내용
PUT /users) 호출 시 Swagger에서 발생하는 Content-Type 에러 해결변경 사항
UserController@Operation어노테이션에requestBody및encoding설정을 추가하여, Multipart 요청 시request파트가application/json으로 전송되도록 명시UserServicemodifyUserInfo메서드 내 로직 순서 변경: 엔티티가 업데이트되기 전에oldImageUrl을 미리 백업하여, 변경 전 이미지가 삭제되도록 수정S3Uploaderdelete()메서드에URLDecoder.decode()추가 (특수문자 포함된 파일명 처리)StringUtils.hasText()도입 (Null 및 빈 문자열""방지)트러블 슈팅
Swagger Content-Type 문제
application/octet-stream으로 전송되어HttpMediaTypeNotSupportedException발생@Operation설정을 통해content-type: application/json을 강제하도록 수정S3 이미지 삭제 실패 (인코딩)
%20), S3 키값과 불일치하여 삭제되지 않음URLDecoder를 사용하여 파일명을 UTF-8로 디코딩한 후deleteObject요청빈 문자열 에러
""(빈 문자열)로 저장되어 있어,if (url != null)조건을 통과해 삭제 로직 수행 중 에러 발생StringUtils.hasText()를 사용하여 빈 문자열까지 안전하게 필터링참고 사항
코드 리뷰 전 확인 체크리스트
type :)Summary by CodeRabbit
릴리스 노트
버그 수정
문서화
✏️ Tip: You can customize this high-level summary in your review settings.