Conversation
feat: 로그인 응답 필드 추가
feat: 유저 프로퍼티 조회 API 구현
📝 WalkthroughWalkthroughA new API endpoint and supporting infrastructure are introduced to expose user property information via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
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
`@application/src/main/java/com/pinback/application/user/usecase/UserManagementUsecase.java`:
- Around line 100-106: getUserProperty in UserManagementUsecase calls
getUser.getJob().getValue() which can NPE when job is null; change this to
obtain the user via userGetServicePort.findById(user.getId()) and pass a
null-safe job value to UserPropertyResponse.of by checking User.hasJob() (or
user.getJob() != null) and using job.getValue() only when present, otherwise
pass null, mirroring the pattern used in AuthUsecase and
GetSharedArticleUsecase.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0adc76b0-bb84-48c6-8c03-d40d7cb30731
📒 Files selected for processing (6)
api/src/main/java/com/pinback/api/user/controller/UserControllerV3.javaapplication/src/main/java/com/pinback/application/auth/usecase/AuthUsecase.javaapplication/src/main/java/com/pinback/application/google/dto/response/GoogleLoginResponseV3.javaapplication/src/main/java/com/pinback/application/user/dto/response/UserPropertyResponse.javaapplication/src/main/java/com/pinback/application/user/port/in/UserManagementPort.javaapplication/src/main/java/com/pinback/application/user/usecase/UserManagementUsecase.java
| @Override | ||
| @Transactional(readOnly = true) | ||
| public UserPropertyResponse getUserProperty(User user) { | ||
| User getUser = userGetServicePort.findById(user.getId()); | ||
|
|
||
| return UserPropertyResponse.of(getUser.getId(), getUser.getJob().getValue()); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check how other methods handle potentially null job field
rg -n -A3 -B3 'getJob\(\)' --type=java
# Check the hasJob() method implementation
ast-grep --pattern $'public boolean hasJob() {
$$$
}'Repository: Pinback-Team/pinback-server
Length of output: 6183
Potential NullPointerException when user has no job set.
The job field is nullable (confirmed by the hasJob() method in User.java). Calling getUser.getJob().getValue() on line 105 will throw a NullPointerException for users who haven't set their job role.
Other query methods in the codebase handle this consistently: AuthUsecase.java (line 170) uses updatedUser.hasJob() ? updatedUser.getJob().getValue() : null, and GetSharedArticleUsecase.java (line 30) explicitly checks if (user.getJob() == null) before access.
Proposed fix with null-safe handling
`@Override`
`@Transactional`(readOnly = true)
public UserPropertyResponse getUserProperty(User user) {
User getUser = userGetServicePort.findById(user.getId());
-
- return UserPropertyResponse.of(getUser.getId(), getUser.getJob().getValue());
+ String jobRole = getUser.getJob() != null ? getUser.getJob().getValue() : null;
+ return UserPropertyResponse.of(getUser.getId(), jobRole);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @Override | |
| @Transactional(readOnly = true) | |
| public UserPropertyResponse getUserProperty(User user) { | |
| User getUser = userGetServicePort.findById(user.getId()); | |
| return UserPropertyResponse.of(getUser.getId(), getUser.getJob().getValue()); | |
| } | |
| `@Override` | |
| `@Transactional`(readOnly = true) | |
| public UserPropertyResponse getUserProperty(User user) { | |
| User getUser = userGetServicePort.findById(user.getId()); | |
| String jobRole = getUser.getJob() != null ? getUser.getJob().getValue() : null; | |
| return UserPropertyResponse.of(getUser.getId(), jobRole); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@application/src/main/java/com/pinback/application/user/usecase/UserManagementUsecase.java`
around lines 100 - 106, getUserProperty in UserManagementUsecase calls
getUser.getJob().getValue() which can NPE when job is null; change this to
obtain the user via userGetServicePort.findById(user.getId()) and pass a
null-safe job value to UserPropertyResponse.of by checking User.hasJob() (or
user.getJob() != null) and using job.getValue() only when present, otherwise
pass null, mirroring the pattern used in AuthUsecase and
GetSharedArticleUsecase.
🚀 PR 요약
목적이 무엇인가요? - 지우고 작성
✨ PR 상세 내용
어떤 부분이 어떻게 변경이 되었나요? - 지우고 작성
🚨 주의 사항
주의할 부분이 무엇인가요? - 지우고 작성
✅ 체크 리스트
Summary by CodeRabbit