fix: PolicyMapper에 길이 상한 절단 가드 추가 — 긴 원본값이 정책 1건을 통째로 버리는 문제 - #221
Merged
Conversation
외부 API 원본이 VARCHAR 컬럼 상한을 넘으면 그대로 INSERT를 시도하다 Data truncation으로 정책 1건 전체가 저장 실패하던 문제를 고쳤다(#207 사례). PolicyMapper 클래스 javadoc의 실패 격리 원칙(필드 하나 파싱 실패는 그 필드만 null 처리)을 길이 초과에도 동일하게 적용한다 — 상한 초과 시 경고 로그 (plcyNo·필드명·실제 길이·상한)를 남기고 잘라서 저장하며 예외를 던지지 않는다. - policy_no, title, description, keywords, category, middle_category, organization_name, job_codes, school_codes, 각종 code, URL 3종, application_period_raw, operating_institution_name 등 Policy 엔티티의 @column(length = ...) VARCHAR 필드에 적용. TEXT/LONGTEXT 컬럼은 제외. - PolicyMapperLengthLimitsTest: 매퍼의 길이 상한 상수가 Policy @column(length)와 어긋나면 리플렉션으로 잡아내 드리프트를 방지. - PolicyMapperTest: 길이 초과 시 실제로 잘려서 저장되는지, 경계값(정확히 상한)은 잘리지 않는지, 경고 로그에 plcyNo·필드·길이·상한이 담기는지 검증. - PolicySyncServiceTest: 기존 실패율 테스트가 title 길이 초과를 DB 저장 실패 트리거로 썼는데 이제는 절단되어 성공하므로, plcyNm 누락(title NOT NULL 위반)으로 트리거를 바꿔 동일한 실패율 계산·기록 시나리오를 유지했다. Closes #208
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Reviewed by step-3.7-flash · Input: 115.5K · Output: 10.6K · Cached: 291.7K |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 내용
PolicyMapper에 컬럼 길이 상한 절단 헬퍼(truncate)를 추가했다. 상한 초과 시 예외 대신 경고 로그(plcyNo·필드명·실제 길이·상한)를 남기고 잘라서 저장한다 — 기존에는 외부 API 원본이 컬럼 상한을 넘으면 그대로 INSERT를 시도하다Data truncation으로 정책 1건 전체가 저장 실패했다(fix: 정책 수집이 매 회차 12건 실패 — business_period_etc/URL 컬럼 길이 부족 #207 사례).@Column(length = ...)VARCHAR 필드 전체(policy_no, title, description, keywords, category, middle_category, organization_name, job_codes, school_codes, income_condition_code, marital_status_code, major_codes, specialization_codes, application_period_type, application_period_raw, application_url, reference_url1/2, age_limit_flag, operating_institution_name, approval_status_code)에 길이 가드를 적용했다.TEXT/LONGTEXT컬럼(길이 제한 없음)은 대상에서 제외했다.PolicyMapperLengthLimitsTest를 추가해, 매퍼의 길이 상한 상수가Policy의@Column(length)와 어긋나면 리플렉션으로 비교해 실패하도록 해서 두 곳의 드리프트를 막았다.PolicyMapperTest에 길이 초과 시 실제로 잘려서 저장되는지(E), 상한과 정확히 같은 길이는 잘리지 않는지(경계), 경고 로그에 정책번호·필드명·실제 길이·상한이 담기는지, 상한 내 정상 값은 경고 로그가 없는지를 검증하는 테스트를 추가했다(Log4j2 커스텀 Appender로 WARN 로그를 캡처).PolicySyncServiceTest의 실패율 테스트가 title 길이 초과를 DB 저장 실패 트리거로 쓰고 있었는데, 이번 수정으로 그 값은 절단되어 더 이상 저장이 실패하지 않는다. 트리거를plcyNm누락(title NOT NULL 위반)으로 바꿔 동일한 실패율 계산·기록 시나리오를 그대로 유지했다.검증
export JAVA_HOME="$HOME/.sdkman/candidates/java/21.0.10-tem"./gradlew test --tests "com.bop.youthpick.sync.service.PolicyMapperTest" --tests "com.bop.youthpick.sync.service.PolicyMapperLengthLimitsTest"— 통과./gradlew test --tests "com.bop.youthpick.sync.service.PolicySyncServiceTest"— 통과 (실패율 트리거 변경 후)./gradlew spotlessApply후./gradlew spotlessCheck— 통과./gradlew test(전체) — 541개 테스트 전부 통과, 실패/에러 0건연결 이슈
Closes #208