[Fix] name nullable true로 변경#68
Conversation
📝 WalkthroughWalkthroughA single JPA entity field constraint in the ChangesUser Entity Nullability Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java (1)
33-34: 🏗️ Heavy liftReassess null-safety risk for
User.name
User.nameis nullable (@Column(nullable = true)), but the codebase paths that reference theUserentity do not appear to read it viaUser#getName()/user.getName(). The onlygetName()usages found in those files were for other entities (e.g.,company.getName()), so the claimed direct NPE risk isn’t evidenced.
Ifnamemust be present for business logic, enforce it with validation (e.g.,@NotBlank) and/or make the column non-null.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java` around lines 33 - 34, The User.name field is currently nullable via `@Column`(nullable = true) which may allow unexpected nulls; decide whether name is required by business logic and either make the column non-nullable (remove nullable=true) or add bean validation such as `@NotBlank` on the field and enforce validation where User instances are created/updated (references: User.name and User#getName()). Update persistence mapping and input/DTO validation paths accordingly so callers cannot persist or accept a null/blank name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java`:
- Around line 33-34: User.name was changed to nullable via `@Column`(nullable =
true) but no explicit schema migration exists; add a Flyway/Liquibase migration
that alters the users.name column to allow NULL (or add a new migration SQL in
src/main/resources/db/migration) OR ensure production uses Hibernate DDL-auto to
apply this change by documenting/enforcing application-prod.yaml's JPA_DDL_AUTO
value; also audit call sites of User.getName() and any DTOs/serializers that
expose name and update them to accept/serialize null (and update API
contract/docs) to avoid NPEs or contract mismatches.
---
Nitpick comments:
In `@src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java`:
- Around line 33-34: The User.name field is currently nullable via
`@Column`(nullable = true) which may allow unexpected nulls; decide whether name
is required by business logic and either make the column non-nullable (remove
nullable=true) or add bean validation such as `@NotBlank` on the field and enforce
validation where User instances are created/updated (references: User.name and
User#getName()). Update persistence mapping and input/DTO validation paths
accordingly so callers cannot persist or accept a null/blank name.
🪄 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 Plus
Run ID: d1754c0a-f600-443b-80d2-2c8449dee6f7
📒 Files selected for processing (1)
src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java
| @Column(nullable = true) | ||
| private String name; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for database migration files that modify the users.name column
# Search for migration files mentioning 'name' column changes in users table
rg -i "alter.*users.*name|name.*null" --glob '**/db/migration/**' --glob '**/resources/db/**' -C3Repository: JobDri-Developer/BackEnd
Length of output: 217
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Locate migration directories/files =="
# list candidate migration roots
fd -t d -d 4 'db' . | head -n 50
fd -t f -d 6 'V*.sql' . | head -n 50
fd -t f -d 6 '*flyway*' . | head -n 50
fd -t f -d 6 '*liquibase*' . | head -n 50
fd -t f -d 6 '*.sql' '*/migration/*' . | head -n 50 || true
echo
echo "== Find Flyway/Liquibase config =="
rg -n --hidden --no-ignore -S "flyway|liquibase" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Search for migrations mentioning users.name or nullable change =="
# broader search across SQL and migration-related resources
rg -n --hidden -S "(users|user[s]?)[^\\n]{0,50}\\.name|name[^\\n]{0,50}(null|nullable)|ALTER TABLE[^\\n]{0,200}name" \
-g'*.sql' -g'*.yml' -g'*.yaml' -g'*.properties' \
-g'*migration*' \
. || true
echo
echo "== Inspect User entity annotation =="
sed -n '1,140p' src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java | nl -ba | sed -n '25,110p'Repository: JobDri-Developer/BackEnd
Length of output: 447
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Search for downstream usage of user.name / getName / name field =="
rg -n --hidden -S "\bgetName\s*\(|\bname\s*[:=]" src/main/java/com/jobdri/jobdri_api/domain src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Search for null checks on name =="
rg -n --hidden -S "name\s*!=\s*null|Objects\.nonNull\s*\(\s*.*name|if\s*\(\s*.*name\s*!=\s*null" src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Search for potential NPE: name.toString / concat without null check =="
rg -n --hidden -S "\.name\.|name\.toString|name\s*\+\s*|String\.valueOf\s*\(\s*.*name\s*\)" src/main/java/com/jobdri/jobdri_api || trueRepository: JobDri-Developer/BackEnd
Length of output: 20571
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Locate migration directories/files =="
# list candidate migration roots
fd -t d -d 6 -S 'migration' . | head -n 50 || true
fd -t f -d 8 -S 'V*.sql' . | head -n 50 || true
fd -t f -d 8 -S '*flyway*' . | head -n 50 || true
fd -t f -d 8 -S '*liquibase*' . | head -n 50 || true
fd -t f -d 10 'db/migration' . | head -n 50 || true
echo
echo "== Find Flyway/Liquibase config =="
rg -n --hidden --no-ignore -S "flyway|liquibase" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Search for migrations mentioning users.name or nullable change =="
rg -n --hidden -S "(users|user[s]?)[^\n]{0,80}\.name|name[^\n]{0,80}(null|nullable)|ALTER TABLE[^\n]{0,200}name|MODIFY COLUMN[^\n]{0,200}name" \
-g'*.sql' -g'*.yml' -g'*.yaml' -g'*.properties' \
-g'*migration*' \
. || true
echo
echo "== Inspect User entity annotation around the changed lines =="
nl -ba src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java | sed -n '20,110p'
echo
echo "== Scan downstream usage of User.name (getName/name field) =="
rg -n --hidden -S "\bgetName\s*\(|\bname\b" src/main/java/com/jobdri/jobdri_api/domain src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Look for explicit null checks for name =="
rg -n --hidden -S "name\s*!=\s*null|Objects\.nonNull\s*\(\s*.*name|if\s*\(\s*.*name\s*!=\s*null" src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Look for likely NPE patterns using name =="
rg -n --hidden -S "\.name\.|name\.toString|name\s*\+\s*|String\.valueOf\s*\(\s*.*name\s*\)" src/main/java/com/jobdri/jobdri_api || trueRepository: JobDri-Developer/BackEnd
Length of output: 936
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Inspect User.java name field annotations (around line 33-40) =="
sed -n '1,120p' src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java | cat -n | sed -n '20,60p'
echo
echo "== Find where schema.sql is used/loaded =="
rg -n --hidden -S "schema\.sql|spring\.sql\.init|ddl-auto|create|update" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Search for JPA migration tools config (flyway/liquibase) =="
rg -n --hidden -S "flyway|liquibase" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Inspect users.name definition in schema.sql =="
ls -la src/main/resources/schema.sql 2>/dev/null || true
rg -n --hidden -S "(create table users|alter table users|users\\b.*name|name\\b.*users|MODIFY COLUMN.*name|CHANGE COLUMN.*name)" src/main/resources/schema.sql || true
echo
echo "== Show CREATE TABLE users (and nearby lines) from schema.sql =="
rg -n --hidden -S "create table users|users\\b" src/main/resources/schema.sql -n -S -m 20 -g'*.sql' || true
rg -n --hidden -S "create table users" -C 30 src/main/resources/schema.sql || true
echo
echo "== Search repo for any DDL touching users.name anywhere (non-migration paths too) =="
rg -n --hidden -S "(alter table users|create table users|users\\b.*name|name\\b.*users)(.{0,120})\\b(null|nullable)\\b" \
--glob'*.sql' --glob'*.properties' --glob'*.yml' --glob'*.yaml' . || true
echo
echo "== Search specifically for User.getName() usage =="
rg -n --hidden -S "User\\s*\\)|getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api || trueRepository: JobDri-Developer/BackEnd
Length of output: 3888
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Inspect schema.sql: users table definition =="
# show around CREATE TABLE users
rg -n --hidden -S "create table users" -n src/main/resources/schema.sql || true
# print lines around it (best-effort)
awk 'NR>=1{if($0~"create table users"){start=NR-20; if(start<1) start=1; end=NR+80} } NR>=start && NR<=end{print NR ":" $0}' src/main/resources/schema.sql || true
# if awk above didn't trigger, just show any lines mentioning "users" and "name"
echo
rg -n --hidden -S "users|\\bname\\b" src/main/resources/schema.sql | head -n 200
echo
echo "== Inspect application yaml for spring.sql.init.* (schema.sql usage) =="
rg -n --hidden -S "spring\\.sql\\.init|schema\\.sql" -g'*.yml' -g'*.yaml' src/main/resources
echo
echo "== Inspect User entity factories (signup/createSocialUser) =="
sed -n '1,220p' src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java | nl -ba | sed -n '1,140p'
echo
echo "== Inspect any usage of User.name specifically =="
# try to find "user.getName()" pattern; also look for "User" variable types near getName usage
rg -n --hidden -S "user\\.getName\\s*\\(" src/main/java/com/jobdri/jobdri_api || true
rg -n --hidden -S "getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api/domain/user || true
# also search for "name" field on User via builder or constructor usage
rg -n --hidden -S "new\\s+User\\s*\\(|User\\.builder|\\.name\\s*=\\s*|\\bname\\b\\s*,\\s*.*User" src/main/java/com/jobdri/jobdri_api/domain/user || trueRepository: JobDri-Developer/BackEnd
Length of output: 118
🏁 Script executed:
#!/bin/bash
set -uo pipefail
FILE="src/main/resources/schema.sql"
USER_FILE="src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java"
echo "== schema.sql: locate CREATE TABLE users block =="
line=$(rg -n "create table users" "$FILE" || true | head -n1 | cut -d: -f1)
echo "create table users line: ${line:-N/A}"
if [ -n "${line:-}" ]; then
start=$((line>40 ? line-40 : 1))
end=$((line+140))
sed -n "${start},${end}p" "$FILE" | cat -n | sed -n '1,220p'
fi
echo
echo "== schema.sql: find column definition for name in users table =="
rg -n -S "users.*name|\\bname\\b" "$FILE" | head -n 80 || true
echo
echo "== schema.sql init / ddl-auto in yaml =="
rg -n -S "spring\\.sql\\.init|ddl-auto" src/main/resources/application-dev.yaml src/main/resources/application-prod.yaml src/test/resources/application-test.yaml || true
echo
echo "== User.java: show fields + signup/createSocialUser =="
sed -n '1,220p' "$USER_FILE" | cat -n | sed -n '1,220p'
echo
echo "== User.name usage: search for .getName() and direct name field usage in domain =="
rg -n --hidden -S "user\\.getName\\s*\\(|\\bgetName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api/domain/user src/main/java/com/jobdri/jobdri_api/domain || trueRepository: JobDri-Developer/BackEnd
Length of output: 5395
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Inspect src/main/resources/schema.sql for users/name column =="
wc -l src/main/resources/schema.sql
sed -n '1,160p' src/main/resources/schema.sql | nl -ba | head -n 160
echo
rg -n -S "users|\\buser\\b|\\bname\\b" src/main/resources/schema.sql | head -n 200
echo
# print sections around "users" if present
if rg -n -S -m 1 "users" src/main/resources/schema.sql >/dev/null; then
line=$(rg -n -S -m 1 "users" src/main/resources/schema.sql | cut -d: -f1)
start=$((line>120 ? line-120 : 1))
end=$((line+240))
sed -n "${start},${end}p" src/main/resources/schema.sql | nl -ba | head -n 260
fi
echo
echo "== Check how schema.sql / sql init is configured in YAML =="
rg -n --hidden -S "spring\\.sql\\.init|schema\\.sql" -g'*.yml' -g'*.yaml' src/main/resources src/test/resources || true
echo
echo "== Inspect ddl-auto config in prod/dev/test =="
for f in src/main/resources/application-dev.yaml src/main/resources/application-prod.yaml src/test/resources/application-test.yaml; do
echo "--- $f ---"
sed -n '1,120p' "$f" | nl -ba
done
echo
echo "== Check for Flyway/Liquibase config =="
rg -n --hidden -S "flyway|liquibase" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Find where User.signup / createSocialUser are called =="
rg -n --hidden -S "User\\.signup\\s*\\(|User\\.createSocialUser\\s*\\(" src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Inspect CustomOAuth2UserService: how name is derived =="
sed -n '1,140p' src/main/java/com/jobdri/jobdri_api/domain/auth/service/CustomOAuth2UserService.java | nl -ba
echo
echo "== Inspect OAuth2AuthenticationSuccessHandler (if it maps name) =="
sed -n '1,160p' src/main/java/com/jobdri/jobdri_api/domain/auth/handler/OAuth2AuthenticationSuccessHandler.java | nl -ba
echo
echo "== Search for user.name usage in DTOs/services with likely null-sensitivity =="
rg -n --hidden -S "getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api/domain/user || true
rg -n --hidden -S "\\.getName\\s*\\(" src/main/java/com/jobdri/jobdri_api | head -n 200 || trueRepository: JobDri-Developer/BackEnd
Length of output: 228
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== schema.sql (entire file) =="
cat src/main/resources/schema.sql
echo
echo "== Inspect ddl-auto + spring.sql.init in application yaml =="
for f in src/main/resources/application-dev.yaml src/main/resources/application-prod.yaml src/test/resources/application-test.yaml; do
echo "--- $f ---"
rg -n "ddl-auto|spring\\.sql\\.init|schema\\.sql" "$f" || true
sed -n '1,120p' "$f" | cat -n
done
echo
echo "== Flyway/Liquibase config presence (anywhere) =="
rg -n --hidden -S "flyway|liquibase" -g'*.yml' -g'*.yaml' -g'*.properties' . || true
echo
echo "== Search for actual usage of User.getName() (Lombok getter) =="
# direct method calls
rg -n --hidden -S "getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api/domain/user src/main/java/com/jobdri/jobdri_api/domain || true
# patterns that include variables with user context
rg -n --hidden -S "(user|usr|userDto|userDto|principal)\\.[\\w$]*getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api || true
# builder/DTO mapping where user name might be set
rg -n --hidden -S "name\\s*=\\s*.*(user|principal|usr)" src/main/java/com/jobdri/jobdri_api || trueRepository: JobDri-Developer/BackEnd
Length of output: 11928
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Find user.getName() / principal.getName() callsites =="
rg -n --hidden -S "\buser\w*\s*\.\s*getName\s*\(" src/main/java/com/jobdri/jobdri_api || true
rg -n --hidden -S "\bprincipal\w*\s*\.\s*getName\s*\(" src/main/java/com/jobdri/jobdri_api || true
rg -n --hidden -S "\bcurrentUser\w*\s*\.\s*getName\s*\(" src/main/java/com/jobdri/jobdri_api || true
echo
echo "== Show getName() callsites near user DTO/entity types =="
rg -n --hidden -S "getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api/domain | head -n 200 || true
echo
echo "== Search for any usage of field/property named 'name' in User-related code =="
rg -n --hidden -S "\.name\\b" src/main/java/com/jobdri/jobdri_api/domain/user || trueRepository: JobDri-Developer/BackEnd
Length of output: 1388
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Look for migration tooling directories/files (migration/db/flyway/liquibase) =="
# directories named migration/db/flyway/liquibase
find . -maxdepth 6 -type d \( -iname '*migration*' -o -iname '*flyway*' -o -iname '*liquibase*' -o -iname 'db' \) 2>/dev/null | head -n 200
echo
echo "== Look for Flyway versioned SQL files (V__*.sql) =="
find . -maxdepth 8 -type f -iname 'V*.sql' 2>/dev/null | head -n 200
echo
echo "== Look for any SQL that alters users.name =="
rg -n --hidden -S "(alter table\\s+users|create table\\s+users|users\\s*\\(.*name|\\bname\\b.*users)" \
--glob'*.sql' . || true
echo
echo "== Search for user.name usage in domain/user =="
rg -n --hidden -S "\bUser\b|\\bgetName\\b|\\bname\\b" src/main/java/com/jobdri/jobdri_api/domain/user || trueRepository: JobDri-Developer/BackEnd
Length of output: 2582
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Look for migration tooling directories/files (migration/db/flyway/liquibase) =="
# directories named migration/db/flyway/liquibase
find . -maxdepth 6 -type d \( -iname '*migration*' -o -iname '*flyway*' -o -iname '*liquibase*' -o -iname 'db' \) 2>/dev/null | head -n 200
echo
echo "== Look for Flyway versioned SQL files (V__*.sql) =="
find . -maxdepth 8 -type f -iname 'V*.sql' 2>/dev/null | head -n 200
echo
echo "== Look for any SQL that alters users.name =="
rg -n --hidden -S "(alter table\\s+users|create table\\s+users|users\\s*\\(.*name|\\bname\\b.*users)" \
--glob'*.sql' . || true
echo
echo "== Search for user.name usage in domain/user =="
rg -n --hidden -S "\bUser\b|\\bgetName\\b|\\bname\\b" src/main/java/com/jobdri/jobdri_api/domain/user || trueRepository: JobDri-Developer/BackEnd
Length of output: 2582
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Inspect src/main/java/.../domain/user/service/UserService.java =="
sed -n '1,200p' src/main/java/com/jobdri/jobdri_api/domain/user/service/UserService.java | cat -n
echo
echo "== List files under domain/user =="
find src/main/java/com/jobdri/jobdri_api/domain/user -maxdepth 4 -type f | head -n 200
echo
echo "== Search for DTOs/mappings that reference User.name =="
rg -n --hidden -S "(User|user)\\.(getName\\s*\\(\\s*\\)|name)\\b" src/main/java/com/jobdri/jobdri_api/domain/user src/main/java/com/jobdri/jobdri_api/domain \
|| true
echo
echo "== Search for potential user-name DTO fields =="
rg -n --hidden -S "\\buser(Name|name)\\b|\\bprofile(Name|name)\\b" src/main/java/com/jobdri/jobdri_api/domain src/main/java/com/jobdri/jobdri_api/global \
|| true
echo
echo "== Broad search for .getName() callsites (first 200 matches) =="
rg -n --hidden -S "\\.getName\\s*\\(\\s*\\)" src/main/java/com/jobdri/jobdri_api | head -n 200 || trueRepository: JobDri-Developer/BackEnd
Length of output: 3335
Add an explicit migration (or guarantee prod schema updates) for users.name nullability
User.nameis now@Column(nullable = true)(User.java, lines ~33-34). No Flyway/Liquibase migration files/config were found, andsrc/main/resources/schema.sqldoes not define theuserstable/column (it only has extensions/indexes). Production schema updates therefore rely on Hibernateddl-auto(application-prod.yaml:${JPA_DDL_AUTO:update}); ifJPA_DDL_AUTOis overridden (or disabled) in prod, the column nullability change may not be applied—add a migration or enforceddl-autobehavior for this change.- Null-safety: no callsites of
User.getName()/User.namewere found beyond the factory methods, but confirm any API/DTO that exposesUser.namehandlesnull(and that the contract is updated accordingly).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/java/com/jobdri/jobdri_api/domain/user/entity/User.java` around
lines 33 - 34, User.name was changed to nullable via `@Column`(nullable = true)
but no explicit schema migration exists; add a Flyway/Liquibase migration that
alters the users.name column to allow NULL (or add a new migration SQL in
src/main/resources/db/migration) OR ensure production uses Hibernate DDL-auto to
apply this change by documenting/enforcing application-prod.yaml's JPA_DDL_AUTO
value; also audit call sites of User.getName() and any DTOs/serializers that
expose name and update them to accept/serialize null (and update API
contract/docs) to avoid NPEs or contract mismatches.
✨ 어떤 이유로 PR를 하셨나요?
📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요
📸 작업 화면 스크린샷
🚨 관련 이슈 번호 [ ]
Summary by CodeRabbit