Skip to content

refactor: 프로필 이미지 업로드 제한 10MB 변경 및 소셜 로그인 프로필 수정 오류 수정#138

Merged
neibler merged 1 commit intodevelopfrom
feature/136
Feb 17, 2026
Merged

refactor: 프로필 이미지 업로드 제한 10MB 변경 및 소셜 로그인 프로필 수정 오류 수정#138
neibler merged 1 commit intodevelopfrom
feature/136

Conversation

@neibler
Copy link
Copy Markdown
Contributor

@neibler neibler commented Feb 17, 2026

🔍️ 작업 내용

  • Closes #
    refactor: 프로필 이미지 업로드 제한 10MB 변경 및 소셜 로그인 프로필 수정 오류 수정

✨ 상세 설명

🛠️ 추후 리팩토링 및 고도화 계획

📸 스크린샷 (선택)

💬 리뷰 요구사항

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 이미지 삭제 시 발생할 수 있는 오류 방지
  • 개선 사항

    • 파일 업로드 크기 제한을 5MB에서 10MB로 확대

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 17, 2026

Walkthrough

S3 이미지 삭제 시 URL 접두어 검증을 추가하여 외부 URL 처리를 방지하고, 멀티파트 파일 업로드 크기 제한을 5MB에서 10MB로 상향 조정했습니다.

Changes

Cohort / File(s) Summary
S3 이미지 서비스
src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java
S3ImageService.delete() 메서드에 URL 접두어 검증 로직 추가. 제공된 imageUrl이 S3 생성 접두어로 시작하지 않으면 조기 반환하여 불필요한 처리 차단.
스프링 설정
src/main/resources/application.yml
멀티파트 파일 업로드 크기 제한(max-file-size, max-request-size) 5MB → 10MB로 상향.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive PR 제목은 프로필 이미지 업로드 제한을 10MB로 변경하고 소셜 로그인 프로필 수정 오류를 수정한다는 두 가지 주요 변경사항을 언급하나, 실제 변경 사항은 S3ImageService의 guard 로직 추가(네 번째 변경)와 application.yml의 파일 크기 제한 변경(두 번째 변경)만 포함되어 있습니다. 제목에서 언급된 '소셜 로그인 프로필 수정 오류 수정'이 실제 코드 변경에 반영되어 있는지 확인하거나, 제목을 실제 변경 사항과 정확히 일치하도록 수정해주세요.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/136

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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
Copy Markdown
Contributor

@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

🧹 Nitpick comments (1)
src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java (1)

121-128: extractKey의 prefix 검증이 delete guard와 중복됨

Line 77에서 이미 startsWith(generatePrefix()) 검증을 수행한 뒤 extractKey를 호출하므로, Line 123의 동일한 검증은 사실상 도달 불가능한 코드가 되었습니다. generatePrefix()가 매번 문자열을 생성하므로 불필요한 호출이기도 합니다. prefix를 지역 변수로 추출하거나, extractKey 내부 검증을 제거하는 것을 고려해 보세요.

♻️ 리팩토링 제안: prefix를 한 번만 생성
 public void delete(String imageUrl) {
-	if (!imageUrl.startsWith(generatePrefix())) {
+	String prefix = generatePrefix();
+	if (imageUrl == null || !imageUrl.startsWith(prefix)) {
 		log.info("S3 URL이 아니므로 삭제 생략: {}", imageUrl);
 		return;
 	}
-	String key = extractKey(imageUrl);
+	String key = imageUrl.substring(prefix.length());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java` around
lines 121 - 128, The extractKey method duplicates a prefix check already done by
the delete guard and repeatedly calls generatePrefix(); fix by removing the
redundant startsWith validation inside extractKey and rely on the caller's
check, or better, change extractKey(String imageUrl, String prefix) (or have the
caller compute and pass a cached prefix) so generatePrefix() is invoked only
once and the method simply returns imageUrl.substring(prefix.length()); update
callers (e.g., the delete flow that currently calls extractKey and performs the
startsWith check) to pass the computed prefix and keep error handling where the
initial guard detects unexpected URLs.
🤖 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/com/ongil/backend/global/config/s3/S3ImageService.java`:
- Around line 76-80: The delete(String imageUrl) method should defensively
handle null and avoid duplicating the S3-prefix check already present in
extractKey(String imageUrl): add a null guard at the top of delete (e.g.,
Objects.requireNonNull(imageUrl, "imageUrl must not be null") or an explicit
null-check that logs and returns) and remove the startsWith(generatePrefix())
check from delete so that validation of the URL format is centralized in
extractKey(String imageUrl) (ensure extractKey throws a clear
IllegalArgumentException or logs when the URL is not an S3 URL).

---

Nitpick comments:
In `@src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java`:
- Around line 121-128: The extractKey method duplicates a prefix check already
done by the delete guard and repeatedly calls generatePrefix(); fix by removing
the redundant startsWith validation inside extractKey and rely on the caller's
check, or better, change extractKey(String imageUrl, String prefix) (or have the
caller compute and pass a cached prefix) so generatePrefix() is invoked only
once and the method simply returns imageUrl.substring(prefix.length()); update
callers (e.g., the delete flow that currently calls extractKey and performs the
startsWith check) to pass the computed prefix and keep error handling where the
initial guard detects unexpected URLs.

Comment on lines 76 to +80
public void delete(String imageUrl) {
if (!imageUrl.startsWith(generatePrefix())) {
log.info("S3 URL이 아니므로 삭제 생략: {}", imageUrl);
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "S3ImageService.java" -type f

Repository: IT-Cotato/12th-OnGil-BE

Length of output: 137


🏁 Script executed:

# S3ImageService.java 파일의 delete() 메서드와 관련 메서드 확인
cat -n src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java | head -150

Repository: IT-Cotato/12th-OnGil-BE

Length of output: 4969


🏁 Script executed:

# delete() 메서드 호출부 검색 (테스트 제외)
rg -n 'delete\(' src/main/java --type=java -A 2 | grep -v test

Repository: IT-Cotato/12th-OnGil-BE

Length of output: 4447


🏁 Script executed:

sed -n '50,75p' src/main/java/com/ongil/backend/domain/user/service/UserService.java | cat -n

Repository: IT-Cotato/12th-OnGil-BE

Length of output: 811


🏁 Script executed:

# delete 메서드를 호출하는 전체 메서드 확인 (각 호출 전후 문맥)
sed -n '50,80p' src/main/java/com/ongil/backend/domain/user/service/UserService.java | cat -n

Repository: IT-Cotato/12th-OnGil-BE

Length of output: 1024


imageUrl 파라미터 방어 로직 추가 권장

현재 UserService의 호출 지점에서는 delete() 호출 전에 null 체크가 되어 있으나, 메서드가 public이고 파라미터에 null 안전성 선언이 없어 향후 호출 시 실수로 null이 전달될 가능성이 있습니다. 예외 처리 관점에서 메서드 입구에서 명시적으로 null을 검증하는 것이 좋은 방식입니다.

또한 Line 77의 startsWith() 검사는 Line 123 extractKey()에서도 동일하게 수행되므로, 중복을 제거하고 책임을 명확히 하기 위해 extractKey()만 검증하도록 정리할 수 있습니다.

수정 제안
 public void delete(String imageUrl) {
+	if (imageUrl == null || !imageUrl.startsWith(generatePrefix())) {
-	if (!imageUrl.startsWith(generatePrefix())) {
 		log.info("S3 URL이 아니므로 삭제 생략: {}", imageUrl);
 		return;
 	}

또는 Objects.requireNonNull() 사용:

+	Objects.requireNonNull(imageUrl, "imageUrl must not be null");
 	if (!imageUrl.startsWith(generatePrefix())) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/ongil/backend/global/config/s3/S3ImageService.java` around
lines 76 - 80, The delete(String imageUrl) method should defensively handle null
and avoid duplicating the S3-prefix check already present in extractKey(String
imageUrl): add a null guard at the top of delete (e.g.,
Objects.requireNonNull(imageUrl, "imageUrl must not be null") or an explicit
null-check that logs and returns) and remove the startsWith(generatePrefix())
check from delete so that validation of the URL format is centralized in
extractKey(String imageUrl) (ensure extractKey throws a clear
IllegalArgumentException or logs when the URL is not an S3 URL).

@neibler neibler merged commit 199679b into develop Feb 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant