Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
🛡️ 문제점
💡 개선 사항
|
hyeonky0w0
left a comment
There was a problem hiding this comment.
수고하셨습니다. 코멘트 확인부탁드립니다
추가로 (이건 반영 안하셔도 되는데 보안상.. 걸리는 부분이 있어서 그냥 말씀드립니다.)현재는 이미지 업로드가 Content-Type만 확인하고 있어 실제로는 JPEG/PNG가 아닌 파일도 이미지인 것처럼 업로드할 수 있을 것 같습니다. 파일 내용까지 함께 확인해 실제 이미지인지 검증하면 더 안전할 것 같습니다.
| String photoUrl = null; | ||
| if (hasImage) { | ||
| validateImageType(image); | ||
| photoUrl = s3Uploader.upload(image, CHAT_PHOTO_DIR + "/" + chatRoomId); |
There was a problem hiding this comment.
S3 업로드 후 DB 저장이 실패하면 사진 객체만 S3에 남을 수 있을 것 같습니다. saveUserMessage()에서 예외가 발생한 경우 업로드한 객체를 삭제하는 보상 처리를 추가하면 좋을 것 같습니다.
| relationshipRepository.findByCharacterId(characterId).ifPresent(relationship -> { | ||
| proactiveContactScheduleRepository.deleteByRelationshipId(relationship.getId()); | ||
| chatRoomRepository.findByRelationshipId(relationship.getId()).ifPresent(chatRoom -> { | ||
| chatPhotoRepository.deleteByChatRoomId(chatRoom.getId()); |
There was a problem hiding this comment.
현재 하드 삭제에서는 chat_photo DB 데이터만 삭제하고 실제 S3 객체는 삭제하지 않는 것 같습니다. 사진 URL을 먼저 조회해 둔 뒤 S3 객체까지 삭제하거나, 별도의 비동기 정리 작업을 두는 방식이 필요해 보입니다.
| .contentType(MediaType.MULTIPART_FORM_DATA) | ||
| .body(body) | ||
| .retrieve() | ||
| .onStatus(HttpStatusCode::isError, (req, res) -> { |
There was a problem hiding this comment.
현재는 S3에 사진이 없는 경우를 제외하면 모든 오류를 다시 시도하도록 되어 있습니다. 그래서 요청 내용이 잘못된 4xx 오류처럼 다시 보내도 해결되지 않는 경우까지 계속 재시도될 수 있습니다. 네트워크 오류나 타임아웃, AI 서버의 5xx 오류만 재시도하고, 4xx 오류는 재시도하지 않고 건너뛰도록 구분하면 좋을 것 같습니다.
🛡️ Issues
💡 Improvements
|
💡 Improvements
|
Summary
Related Issue
Describe your code
"[사진]"(AI 400 방지)ChatMessageWriter신규) — 업로드 중 DB 커넥션 점유 제거max-request-size10→12MBChecklist