Skip to content

fix: 이미지 업로드 시 해상도 검증 로직 제거#424

Merged
dh2906 merged 5 commits intodevelopfrom
fix/image-upload-limit
Mar 21, 2026
Merged

fix: 이미지 업로드 시 해상도 검증 로직 제거#424
dh2906 merged 5 commits intodevelopfrom
fix/image-upload-limit

Conversation

@dh2906
Copy link
Contributor

@dh2906 dh2906 commented Mar 21, 2026

🔍 개요

  • 이미지 업로드 시 해상도가 8000px를 넘는 지 검증하는 로직으로 용량이 큰 이미지를 업로드하지 못하고 있음.

  • 스프링 설정에서 업로드하는 파일의 용량은 최대 20mb로 지정했기에, 해상도의 검증은 오히려 기존 정책을 무시하고 있음.


🚀 주요 변경 내용

  • 해상도 검증 로직으로 인해 스프링에서 설정한 업로드 파일의 최대 용량이 무의미해지는 것을 해결했습니다.

  • 업로드 파일이 최대 용량을 넘으면 MaxUploadSizeExceededException이 발생하지만, 이에 대한 핸들러가 존재하지 않아 이를 추가했습니다.

    • (INVALID_FILE_SIZE, 파일 크기가 제한을 초과했습니다.) 메시지 발생

💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@dh2906 dh2906 self-assigned this Mar 21, 2026
@dh2906 dh2906 added the 버그 정상적으로 동작하지 않는 문제 상황 관련 이슈입니다. label Mar 21, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9de2ea0a-1961-4955-a590-fb7c9c9be293

📥 Commits

Reviewing files that changed from the base of the PR and between cc7d7d8 and 1800e89.

📒 Files selected for processing (3)
  • src/main/java/gg/agit/konect/domain/upload/controller/UploadApi.java
  • src/main/java/gg/agit/konect/domain/upload/service/UploadService.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
💤 Files with no reviewable changes (1)
  • src/main/java/gg/agit/konect/domain/upload/service/UploadService.java
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (2)
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/domain/upload/controller/UploadApi.java
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/main/java/gg/agit/konect/domain/upload/controller/UploadApi.java
  • src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java

📝 Walkthrough

Walkthrough

이미지 사전 차원 검증(pre-read) 로직이 제거되고, 멀티파트 최대 업로드 크기 초과 예외에 대한 글로벌 핸들러와 PAYLOAD_TOO_LARGE 응답 코드가 추가되었습니다.

Changes

Cohort / File(s) Summary
이미지 변환 로직
src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
MAX_IMAGE_DIMENSION 및 사전 차원 검증(validateImageDimensions(...)) 호출/구현을 삭제하여, 변환은 곧바로 이미지 읽기 및 EXIF 적용으로 진행됩니다.
업로드 크기 예외 처리
src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java, src/main/java/gg/agit/konect/global/code/ApiResponseCode.java
MaxUploadSizeExceededException에 대한 @ExceptionHandler 추가 및 ApiResponseCode.PAYLOAD_TOO_LARGE(HTTP 413, "파일 크기가 제한을 초과했습니다.") enum 상수 추가로 대용량 업로드 시 표준화된 413 응답을 반환합니다.
업로드 검증 및 API 문서·테스트 업데이트
src/main/java/gg/agit/konect/domain/upload/service/UploadService.java, src/main/java/gg/agit/konect/domain/upload/controller/UploadApi.java, src/test/java/gg/agit/konect/integration/domain/upload/UploadApiTest.java
validateFile(...)에서 파일 크기 사전 검증 제거, OpenAPI 설명의 오류 코드 문구(400→413) 수정, 통합 테스트의 기대 상태 및 코드 값을 PAYLOAD_TOO_LARGE/413으로 업데이트했습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 당근 한 움큼 들고 왔어요,
픽셀 크기 재보던 건 잠시 접어두고,
파일은 바로 WebP로 변신하네요.
너무 크면 살짝 413으로 알려주고,
나는 깡충, 기분이 좋아요! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 변경의 핵심인 해상도 검증 로직 제거를 명확하게 설명하며 실제 변경 사항과 완전히 일치합니다.
Description check ✅ Passed 설명은 해상도 검증 로직 제거, 스프링 업로드 용량 설정과의 충돌, 그리고 추가된 예외 핸들러에 대해 상세하게 설명하여 변경 사항과 관련이 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/image-upload-limit

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java`:
- Around line 79-82: 현재 MaxUploadSizeExceededException을 handle하는
handleMaxUploadSizeExceededException가 ApiResponseCode.INVALID_FILE_SIZE(HTTP
400)를 사용하고 있으므로 HTTP 의미가 어긋납니다; 수정 방법은 ApiResponseCode에 HTTP 413 상태를 나타내는 새
항목(예: PAYLOAD_TOO_LARGE 또는 FILE_TOO_LARGE, 상태코드 413 포함)을 추가하거나
INVALID_FILE_SIZE의 상태 코드를 413으로 변경한 뒤, GlobalExceptionHandler의
handleMaxUploadSizeExceededException가 새 413 기반 ApiResponseCode를 사용하도록 바꾸고
buildErrorResponse가 해당 ApiResponseCode의 HTTP 상태를 응답에 반영하는지(응답 상태값을 전달/사용하는지)
확인하세요; 참조 심볼: MaxUploadSizeExceededException,
handleMaxUploadSizeExceededException, ApiResponseCode.INVALID_FILE_SIZE,
buildErrorResponse.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 615c6379-c7ef-4d6c-ab6b-b9880d94af83

📥 Commits

Reviewing files that changed from the base of the PR and between e616c31 and 37d0a7b.

📒 Files selected for processing (2)
  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java
💤 Files with no reviewable changes (1)
  • src/main/java/gg/agit/konect/domain/upload/service/ImageConversionService.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/gg/agit/konect/global/code/ApiResponseCode.java`:
- Around line 117-118: The enum entry PAYLOAD_TOO_LARGE in ApiResponseCode
currently uses the same message as INVALID_FILE_SIZE; update PAYLOAD_TOO_LARGE's
message to be specific (e.g., "업로드 파일이 최대 용량(20MB)을 초과했습니다.") so clients can
distinguish a 413 payload-too-large server response from the 400
INVALID_FILE_SIZE case; modify the message string in the PAYLOAD_TOO_LARGE enum
constant without altering INVALID_FILE_SIZE.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9eeff733-a13e-4655-9ef6-572ac984da7f

📥 Commits

Reviewing files that changed from the base of the PR and between 37d0a7b and cc7d7d8.

📒 Files selected for processing (2)
  • src/main/java/gg/agit/konect/global/code/ApiResponseCode.java
  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java
  • src/main/java/gg/agit/konect/global/code/ApiResponseCode.java
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java
  • src/main/java/gg/agit/konect/global/code/ApiResponseCode.java
🔇 Additional comments (1)
src/main/java/gg/agit/konect/global/exception/GlobalExceptionHandler.java (1)

79-82: [LEVEL: -] 이전 리뷰에서 지적된 HTTP 상태 코드 문제가 해결되었습니다.

MaxUploadSizeExceededException 발생 시 PAYLOAD_TOO_LARGE (HTTP 413)를 반환하도록 수정되어 HTTP 의미에 맞게 구현되었습니다. 기존 핸들러 패턴과 일관성도 유지됩니다.

@dh2906 dh2906 merged commit fcdedca into develop Mar 21, 2026
3 checks passed
@dh2906 dh2906 deleted the fix/image-upload-limit branch March 21, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 정상적으로 동작하지 않는 문제 상황 관련 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant