Skip to content

Conversation

@yerinchun
Copy link
Contributor

@yerinchun yerinchun commented Jan 8, 2026

#️⃣ 연관된 이슈

관련된 이슈 번호를 적어주세요.
Close #233

✨ 작업 내용 (Summary)

이번 PR에서 작업한 내용을 간략히 설명해주세요. (이미지 첨부 가능)

  • 닉네임 검증 강화: isNicknameChanged가 true일 때만 업데이트를 수행하며, 닉네임이 null인 경우 INVALID_INPUT_VALUE 예외를 발생시켜 데이터 무결성을 보장합니다.
  • 미사용 필드 제거: 기획 변경에 따라 isPublic 필드를 엔티티와 DTO 전반에서 삭제하여 API 명세를 간소화했습니다.

✅ 변경 사항 체크리스트

다음 항목들을 확인하고 체크해주세요.

  • 코드에 영향이 있는 모든 부분에 대한 테스트를 작성하고 실행했나요?
  • 문서를 작성하거나 수정했나요? (필요한 경우)
  • 중요한 변경 사항이 팀에 공유되었나요?

🧪 테스트 결과

코드 변경에 대해 테스트를 수행한 결과를 요약해주세요.

  • 테스트 환경: 로컬
  • 테스트 방법: 스웨거
  • 결과 요약: 테스트 통과

📸 스크린샷

관련된 스크린샷 또는 GIF가 있다면 여기에 첨부해주세요.

isNicknameChanged = true && nickname = null
image


💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.


📎 참고 자료

관련 문서, 레퍼런스 링크 등이 있다면 여기에 첨부해주세요.

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes

    • 닉네임 업데이트 시 빈 값 검증 강화 — 빈 닉네임 입력 시 INVALID_INPUT_VALUE 오류 반환
  • Refactor

    • 사용자 정보 업데이트 API에서 프로필 공개 여부 필드 제거 — 요청/응답 페이로드에서 더 이상 노출되지 않음
  • Chores

    • 잘못된 입력값용 오류 코드/메시지 추가 (COMMON600: 잘못된 입력값입니다.)

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

사용자 정보 업데이트 API에서 사용하지 않는 isPublic 필드를 요청/응답 DTO와 서비스 로직에서 제거했고, 닉네임 변경 처리 로직을 isNicknameChanged == true 및 전달된 nickname != null 일 때만 적용되도록 검증을 강화했습니다. 또한 공통 에러 코드에 INVALID_INPUT_VALUE를 추가했습니다. (45자)

Changes

코호트 / 파일(s) 변경 사항
요청/응답 DTO
\src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoRequestDto.java`, `src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoResponseDto.java``
isPublic 필드 및 관련 Swagger @Schema 제거; Response DTO 빌더/매핑에서 isPublic 할당 제거
서비스 구현
\src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java``
닉네임 처리 보강: isNicknameChanged && nickname != null 조건으로 null/빈값 덮어쓰기 방지, 중복검사 유지; isPublic 업데이트 로직 제거
공통 응답/에러 코드
\src/main/java/com/hrr/backend/global/response/ErrorCode.java``
새로운 에러 코드 INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "COMMON600", "잘못된 입력값입니다.") 추가

Sequence Diagram(s)

(생략 — 변경이 DTO 제거 및 단일 서비스 흐름 검증 강화 중심이므로 시퀀스 다이어그램을 생성하지 않습니다.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

닉네임은 조심해, null은 막고,
안 쓰는 플래그는 가볍게 보냈네.
에러 하나 더해 검증 단단히,
작게 고치니 버그는 살짝 웃네 ✨
깔끔해진 코드, 기분 좋게 퇴근.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 변경 사항의 핵심(닉네임 검증 강화 및 isPublic 필드 제거)을 명확하게 요약하고 있으며, PR 객체와 완벽하게 일치합니다.
Linked Issues check ✅ Passed 코드 변경사항이 Issue #233의 모든 주요 요구사항을 충족합니다: isNicknameChanged 플래그 검증, 닉네임 null/공백 체크, isPublic 필드 완전 제거, 중복 검사 추가.
Out of Scope Changes check ✅ Passed 모든 변경사항이 Issue #233의 명시된 목표와 직접 연관되어 있으며, 범위를 벗어난 변경은 없습니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a0a059 and 1107885.

📒 Files selected for processing (1)
  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java
🔇 Additional comments (2)
src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java (2)

365-384: 닉네임 변경 로직이 PR 요구사항을 정확하게 구현했습니다!

구현 내용이 깔끔합니다:

  • isNicknameChanged 플래그를 통한 명시적 변경 의도 확인
  • null/blank 검증으로 데이터 무결성 보장
  • 기존 닉네임과 동일한 경우 중복 체크를 스킵하는 최적화

로직 흐름을 여러 케이스로 검증했으며, 모두 올바르게 동작합니다.


370-372: DTO 검증이 불완전하므로 서비스 레벨 방어 로직이 필수입니다

UpdateUserInfoRequestDto의 nickname 필드는 @Size(min = 1, max = 20) 만 적용되어 있습니다. @Size길이만 검증하며 null이나 공백 문자열을 차단하지 못합니다. 따라서 서비스 레벨의 isBlank() 검증은 DTO 검증의 공백을 메우는 의도된 방어 로직이며, 중복이 아니라 필수적입니다.

보완 제안: DTO 검증을 강화하려면 @NotBlank 어노테이션을 추가하면, 요청 진입 시점에서 더 일찍 검증할 수 있습니다. (관련 문서: Jakarta Bean Validation - NotBlank)


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.

@yerinchun yerinchun self-assigned this Jan 8, 2026
@yerinchun yerinchun added 🐞 bug 버그 이슈 예린 labels Jan 8, 2026
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java (1)

365-376: PR 목표와 구현 로직이 불일치합니다.

PR 설명에서는 "isNicknameChanged가 true이고 닉네임이 null인 경우 INVALID_INPUT_VALUE 예외를 발생시켜 데이터 무결성을 보장"한다고 명시했으나, 현재 코드는 해당 상황을 조용히 무시합니다.

클라이언트가 명시적으로 닉네임 변경 의사(isNicknameChanged=true)를 밝혔음에도 null 값을 전달하는 것은 잘못된 요청이므로, 예외를 발생시켜 명확히 알려주는 것이 데이터 무결성 측면에서 더 안전합니다.

🔧 PR 목표에 맞춘 수정 제안
-        // isNicknameChanged가 true이고 nickname이 null이 아닐 때만 처리
-        if (Boolean.TRUE.equals(requestDto.getIsNicknameChanged()) && requestDto.getNickname() != null) {
+        // isNicknameChanged가 true일 때 닉네임 검증 및 업데이트
+        if (Boolean.TRUE.equals(requestDto.getIsNicknameChanged())) {
+            // 닉네임 변경 의사를 밝혔는데 null이면 예외 발생
+            if (requestDto.getNickname() == null) {
+                throw new GlobalException(ErrorCode.INVALID_INPUT_VALUE);
+            }
+            
             String nickname = normalize(requestDto.getNickname());
 
             // 자기 닉네임과 다를 때만 중복 체크 및 업데이트
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0971e96 and 4b49ac7.

📒 Files selected for processing (3)
  • src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoRequestDto.java
  • src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoResponseDto.java
  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java
💤 Files with no reviewable changes (2)
  • src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoResponseDto.java
  • src/main/java/com/hrr/backend/domain/user/dto/UpdateUserInfoRequestDto.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-06T08:06:38.145Z
Learnt from: yerinchun
Repo: Hrr-HabbitRoutineResult/hrr-server PR: 26
File: src/main/java/com/hrr/backend/domain/user/entity/User.java:42-44
Timestamp: 2025-11-06T08:06:38.145Z
Learning: In the hrr-server project User entity (src/main/java/com/hrr/backend/domain/user/entity/User.java), the password field is nullable because the application uses social login (OAuth), and social login users do not have passwords stored in the database.

Applied to files:

  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java
🔇 Additional comments (2)
src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java (2)

370-375: 중복 체크 최적화가 잘 되어 있습니다! 👍

자신의 현재 닉네임과 동일한 경우 불필요한 DB 중복 체크를 스킵하는 로직이 효율적입니다.


367-367: DTO 레벨의 닉네임 검증이 이미 적절하게 구현되어 있습니다.

UpdateUserInfoRequestDto@Size(min = 1, max = 20) 애노테이션이 설정되어 있으므로, 빈 문자열이나 공백만 있는 닉네임은 DTO 검증 단계에서 이미 차단됩니다. 이후 normalize() 함수에서 trim을 수행하는 것은 공백 처리를 위한 적절한 설계입니다. 현재 코드는 검증-정규화의 책임 분리가 명확하고 안전한 상태이므로, 추가 조치는 불필요합니다. 👍

Likely an incorrect or invalid review comment.

Copy link
Contributor

@yc3697 yc3697 left a comment

Choose a reason for hiding this comment

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

isNicknameChanged=true인데 nickname이 null인 경우에 명시적으로 예외를 던져줘야 할 것 같아요

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: 0

🧹 Nitpick comments (1)
src/main/java/com/hrr/backend/global/response/ErrorCode.java (1)

15-15: 좋습니다! 범용 입력 검증 에러 코드 추가 👍

INVALID_INPUT_VALUE 에러 코드가 닉네임 검증 강화 요구사항에 잘 부합합니다. 네이밍도 명확하고 BAD_REQUEST 상태도 적절합니다.

다만 에러 코드 번호가 COMMON400에서 COMMON600으로 건너뛰는데, 이것이 의도적인 번호 체계인지 확인해 보시면 좋겠습니다. 일반적으로는 순차적 증가(COMMON401, 402...)를 사용하거나, 카테고리별 번호 범위를 문서화하는 것이 유지보수에 도움이 됩니다.

📚 참고: 에러 코드 번호 체계 예시

만약 카테고리별로 번호 범위를 나누는 전략이라면, 팀 내 문서화를 권장합니다:

  • COMMON400번대: 요청 관련 에러
  • COMMON600번대: 입력값 검증 에러
  • 기타...

또는 순차적 증가 방식:

-INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "COMMON600", "잘못된 입력값입니다."),
+INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "COMMON401", "잘못된 입력값입니다."),
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b49ac7 and c4a0afb.

📒 Files selected for processing (2)
  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java
  • src/main/java/com/hrr/backend/global/response/ErrorCode.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java (1)

365-384: 닉네임 변경 로직의 공백/빈 문자열 검증 보완 필요

null 체크는 추가되었으나, 정규화 이후 공백 또는 빈 문자열에 대한 명시적 검증이 누락되어 있습니다.

근본 원인:

  • UpdateUserInfoRequestDto@Size(min=1, max=20)는 정규화 이전의 문자열 길이만 검증
  • 클라이언트가 " " (공백만 3자)를 전송하면 @Size 검증을 통과
  • 이후 normalize(rawNickname)가 이를 "" (빈 문자열)로 변환
  • 변환된 값에 대한 재검증 없이 DB에 저장됨

문제:

  1. 사용자 닉네임이 빈 문자열로 저장될 수 있음
  2. setNickname() 메서드는 @NotBlank로 더 강한 검증을 수행하는데, updateUserInfo()는 약한 검증만 함 (일관성 부족)

권장 수정:
공백 문자열을 미리 차단하려면 정규화 이후에 검증하세요:

// 변경 플래그는 true인데 값이 null인 경우
if (rawNickname == null || rawNickname.isBlank()) {
    throw new GlobalException(ErrorCode.INVALID_INPUT_VALUE);
}

// 값이 있는 경우 업데이트 진행
String nickname = normalize(rawNickname);

이렇게 수정하면 setNickname() 메서드의 검증 수준과 일치시킬 수 있습니다.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4a0afb and 4a0a059.

📒 Files selected for processing (1)
  • src/main/java/com/hrr/backend/domain/user/service/UserServiceImpl.java


// 자기 닉네임과 다를 때만 중복 체크 및 업데이트
// 변경 플래그는 true인데 값이 null인 경우
if (rawNickname == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

코드래빗 리뷰처럼 isBlank 조건 추가해서 빈 문자열 필터링이 필요할 것 같아요!

Copy link
Contributor

@yc3697 yc3697 left a comment

Choose a reason for hiding this comment

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

확인했습니다 수고하셨어요!

@yerinchun yerinchun merged commit cc56738 into develop Jan 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

예린 🐞 bug 버그 이슈

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 사용자 기본정보 수정 API 닉네임 처리 로직 변경 및 isPublic 삭제

3 participants