Skip to content

[Fix] 영수증 이미지 object key 검증 강화 및 S3 객체 미존재 로그 추가 - #150

Merged
jyvnee merged 1 commit into
developfrom
fix/#148/receipt-image-not-found
Oct 10, 2026
Merged

jyvnee merged 1 commit into
developfrom
fix/#148/receipt-image-not-found

Conversation

@jyvnee

@jyvnee jyvnee commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

개요

프론트엔드에서 영수증 이미지를 S3에 정상 업로드(PUT 200)한 뒤 영수증 분석 API를 호출하면 404 BILL_LOG-E019가 반환됩니다. S3에는 이미지가 정상 저장되어 있지만, 서버가 어떤 object key로 조회했는지 남지 않아 원인을 확정할 수 없습니다.
이 PR은 원인 추적을 위해 S3 객체 미존재 시 조회 key를 로그로 남기고, 발급된 적 없는 형식의 key가 404로 숨겨지지 않도록 영수증 이미지 object key 검증을 강화합니다.

작업 내용

  • S3 객체 미존재 로그: S3ObjectMetadataProvider에서 S3가 404를 반환하면 objectKey와 requestId를 warn 로그로 남깁니다. 공통 컴포넌트이므로 프로필, 그룹 커버, Post-log 사진 확인에도 동일하게 적용됩니다.
  • 영수증 object key 대소문자 검증: ReceiptImageObjectKey.create()가 UUID와 확장자를 대소문자 구분 없이 허용하던 것을 발급 형식(소문자)과 정확히 일치할 때만 허용하도록 변경합니다.
    • S3 key는 대소문자를 구분하므로 기존에는 .JPG나 대문자 UUID처럼 존재할 수 없는 key가 검증을 통과해 404 BILL_LOG-E019로 응답했습니다.
    • 변경 후에는 400 BILL_LOG-E018로 응답해 잘못된 key 전달을 바로 구분할 수 있습니다.

테스트

./gradlew ktlintCheck
./gradlew test
  • 결과: 전부 성공 (582개 테스트 통과, 실패 0)
  • 추가한 테스트
    • ReceiptImageObjectKeyTest(신규): 발급 형식 key 허용, 대문자 확장자 거부, 대문자 UUID 거부

API 변경

  • POST /api/v1/meetings/{meetingId}/bill-log/receipt-analysis: 대소문자가 발급 형식과 다른 object key의 응답이 404 BILL_LOG-E019에서 400 BILL_LOG-E018로 바뀝니다. 서버가 발급한 key를 그대로 전달하는 정상 흐름에는 영향이 없습니다.

DB 및 설정 변경

  • 없음

리뷰 시 참고 사항

  • 이 PR은 원인을 확정하는 수정이 아니라 추적을 위한 수정입니다. dev 배포 후 프론트엔드에서 재현하면 S3 object not found 로그의 key와 S3 객체 목록을 비교해 원인을 확정할 수 있습니다.
  • object key에는 meetingId, userId, UUID만 포함되어 민감 정보에 해당하지 않는다고 판단했습니다.

체크리스트

  • 변경 범위에 맞는 테스트를 실행했습니다.
  • 계층 책임을 지키고 필요한 문서를 갱신했습니다.
  • 비밀번호, 토큰, 개인정보 등 민감정보를 포함하지 않았습니다.
  • 관련 없는 변경을 포함하지 않았습니다.

Summary by CodeRabbit

  • 버그 수정
    • 영수증 이미지 경로의 확장자와 파일 식별자가 발급 형식과 대소문자까지 정확히 일치하는지 확인합니다. 형식과 맞지 않는 경로는 허용되지 않습니다.

@jyvnee jyvnee added the 🛠️ fix 버그 수정 label Oct 10, 2026
@jyvnee jyvnee self-assigned this Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: team-belog/belog-server/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3f2548d-5be9-40e6-9cc1-68172588466f

📥 Commits

Reviewing files that changed from the base of the PR and between 811d381 and 5bb5115.


📒 Files selected for processing (3)
  • src/main/kotlin/org/com/belog/billlog/domain/ReceiptImageObjectKey.kt
  • src/main/kotlin/org/com/belog/global/storage/S3ObjectMetadataProvider.kt
  • src/test/kotlin/org/com/belog/billlog/domain/ReceiptImageObjectKeyTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

영수증 이미지 object key의 확장자와 UUID 검증을 발급 형식과 정확히 일치하도록 변경했습니다. S3 객체 조회에서 404가 발생하면 object key와 request ID를 경고 로그에 기록합니다.

Changes

영수증 이미지 조회

Layer / File(s) Summary
object key 검증과 테스트
src/main/kotlin/org/com/belog/billlog/domain/ReceiptImageObjectKey.kt, src/test/kotlin/org/com/belog/billlog/domain/ReceiptImageObjectKeyTest.kt
확장자는 형식의 표준 확장자와 정확히 일치해야 합니다. UUID는 소문자 정규 문자열과 정확히 일치해야 합니다. 테스트는 발급 형식과 일치하는 경로의 생성 결과와 대소문자가 다른 확장자 및 UUID의 거부를 확인합니다.
S3 404 경고 로그
src/main/kotlin/org/com/belog/global/storage/S3ObjectMetadataProvider.kt
S3 응답 상태가 404이면 기존 not-found 예외를 발생시키기 전에 object key와 request ID를 경고 로그에 기록합니다.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to 5bb51

The change tightens receipt image key validation and adds a diagnostic log for missing S3 objects. Keys issued by the server are unaffected. No actionable merge risk was identified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed 제목이 영수증 이미지 object key 검증 강화와 S3 객체 미존재 로그 추가라는 주요 변경 사항을 정확하고 간결하게 설명합니다.
Description check Passed 개요, 작업 내용, 테스트 결과, API 변경, DB 및 설정 변경, 리뷰 참고 사항, 체크리스트를 모두 작성했습니다. 변경 목적과 영향도 구체적으로 설명합니다.
Linked Issues check Passed 직접 연결된 활성 이슈 [#148]의 코딩 요구사항을 충족합니다. S3ObjectMetadataProvider는 S3 HEAD 응답이 404이면 objectKey와 requestId를 warn 로그에 기록한 뒤 기존 예외를 발생시킵니다. ReceiptImageObjectKey.create()는 확장자와 UUID가 발급 형식의 소문자 문자열과 …
Out of Scope Changes check Passed 변경은 [#148]의 원인 추적과 잘못된 영수증 이미지 key 검증에 한정됩니다. S3 공통 컴포넌트의 404 로그 변경은 이슈가 명시한 공통 적용 범위와 일치합니다. ReceiptImageObjectKeyTest는 변경 동작을 검증하는 지원 테스트입니다. 확인된 변경에서 관련 없는 기능, 설정, DB 변경은 없습니다.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

@jyvnee
jyvnee merged commit ec1b8e4 into develop Oct 10, 2026
2 checks passed
@jyvnee
jyvnee deleted the fix/#148/receipt-image-not-found branch October 10, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 영수증 분석 요청 시 업로드된 이미지를 찾지 못하는 오류

1 participant