Skip to content

Conversation

@hd0rable
Copy link
Member

@hd0rable hd0rable commented Oct 19, 2025

#️⃣ 연관된 이슈

closes #327

📝 작업 내용

  • 책 저장시 description 칼럼에 3000자 제약보다 넘는 책 설명이 들어올경우 2997자까지만 저장후 자른뒤 ... 를 추가하여 db에 저장하도록 수정했습니다.

📸 스크린샷

image

💬 리뷰 요구사항

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

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 버그 수정
    • 도서 설명 처리 로직을 개선했습니다. HTML 이스케이프를 해제한 후 설명이 3,000자 초과 시 자동으로 잘라내고 끝에 "..."을 붙여 표시하여, 과도하게 긴 설명으로 인한 표시 문제를 방지합니다.

@coderabbitai
Copy link

coderabbitai bot commented Oct 19, 2025

Walkthrough

Naver 책 XML 파서에서 description을 HTML 언이스케이프한 뒤 길이를 확인해 3000자를 초과하면 잘라서 "..."를 덧붙여 반환하도록 변경했습니다.

Changes

Cohort / File(s) 변경 요약
설명 길이 제한 로직 추가
src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java
MAX_DESCRIPTION_LENGTH = 3000 상수 추가. description 처리 시 rawDescription = unescape(htmlDescription) 계산 후 길이 검사. 초과 시 (MAX_DESCRIPTION_LENGTH - 3)까지 자르고 "..."를 붙여 최종 description으로 설정, 아니면 원본 사용.

Sequence Diagram(s)

sequenceDiagram
    participant XML as Naver API XML
    participant Parser as NaverBookXmlParser
    participant DB as Database

    XML->>Parser: 책 데이터(XML) 전달
    Parser->>Parser: title, author 등 파싱
    Parser->>Parser: rawDescription = unescape(htmlDescription)
    alt rawDescription.length > MAX_DESCRIPTION_LENGTH
        note right of Parser #f9f0c1: 잘라서 말줄임표 추가\n(truncate + "...")
        Parser->>DB: 저장할 description = truncated + "..."
    else rawDescription.length <= MAX_DESCRIPTION_LENGTH
        Parser->>DB: 저장할 description = rawDescription
    end
    Parser->>DB: 나머지 필드와 함께 저장 요청
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 분

Suggested reviewers

  • seongjunnoh

Poem

🐰 숲속 파서 토끼가 한마디:
설명 길면 살짝 잘라요,
삼천 글자 지키고 말줄임표 달아,
DB엔 깔끔한 한 줄 남기네. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR 제목 "[hotfix] 책 저장시 3000자 넘을경우 ... 처리 추가해서 db 저장하도록 수정"은 변경 사항의 핵심을 명확하게 요약하고 있습니다. 제목은 책 설명이 3000자를 초과할 경우 "..." 처리를 추가하여 데이터베이스에 저장한다는 주요 변경 사항을 정확하게 반영하고 있으며, raw_summary의 내용과 일치합니다. 제목은 간결하고 구체적이며 팀원들이 변경 히스토리를 스캔할 때 주요 변경 사항을 명확하게 이해할 수 있습니다.
Linked Issues Check ✅ Passed PR의 코드 변경 사항은 링크된 이슈 #327의 요구사항을 충족합니다. 이슈에서 요구하는 "책 설명을 3000자 제한을 초과할 경우 자르고 ...을 추가해서 db 저장"이라는 목표는 PR에서 NaverBookXmlParser에 MAX_DESCRIPTION_LENGTH 상수(3000)를 도입하고, parseBookDetail에서 설명 길이를 확인한 후 초과 시 (MAX_DESCRIPTION_LENGTH - suffix 길이)로 자르고 "..."을 추가하는 방식으로 구현되었습니다. 이는 데이터베이스에 저장되는 설명이 3000자 제한을 준수하도록 보장합니다.
Out of Scope Changes Check ✅ Passed PR에서 수정된 파일은 NaverBookXmlParser.java 하나이며, 모든 변경 사항은 링크된 이슈 #327의 요구사항과 직접적으로 관련이 있습니다. MAX_DESCRIPTION_LENGTH 상수 추가와 설명 길이 검증 및 자르기 로직은 정확히 이슈에서 요청한 3000자 제한 처리를 구현하고 있으며, 해당 범위를 벗어난 추가적인 변경 사항은 없습니다.
✨ 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 hotfix/#327-book-description-3000

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2166a8f and 7632374.

📒 Files selected for processing (1)
  • src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

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

@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/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (1)

74-74: 매직 넘버를 상수로 추출하는 것을 고려하세요.

3000이라는 값이 하드코딩되어 있습니다. 이 값이 데이터베이스 컬럼 제약과 연관된 경우, 클래스 레벨이나 설정 파일의 상수로 정의하면 유지보수성이 향상됩니다.

예시:

 public class NaverBookXmlParser {
+    private static final int MAX_DESCRIPTION_LENGTH = 3000;

     public static NaverBookParseResult parseBookList(String xml) {
         ...
     }

     public static NaverDetailBookParseResult parseBookDetail(String xml) {
         ...
                     String rawDescription =  StringEscapeUtils.unescapeHtml4(getTagValue(item, "description"));
                     String description;
                     String suffix = "...";
-                    if (rawDescription.length() > 3000) {
-                        description = rawDescription.substring(0, 3000 - suffix.length()) + suffix;
+                    if (rawDescription.length() > MAX_DESCRIPTION_LENGTH) {
+                        description = rawDescription.substring(0, MAX_DESCRIPTION_LENGTH - suffix.length()) + suffix;
                     } else {
                         description = rawDescription;
                     }
         ...
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 75f1da0 and 32d9b1b.

📒 Files selected for processing (1)
  • src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (2)

71-78: 데이터베이스 컬럼 정의 확인 결과 및 검토의견 재평가

검증 결과, BookJpaEntitydescription 필드는 @Column(length = 3000)으로 정의되어 있으며, 이는 문자 단위 제한입니다. 현재 코드는 3000자 초과 시 2997자로 절단하고 "..."을 추가합니다.

검토의견의 기술적 유효성:

  • Java의 String.substring()은 UTF-16 코드 유닛 단위로 작동하므로, 이론적으로 서로게이트 페어 분할 위험이 존재합니다.

실제 적용 맥락 분석:

  • 네이버 도서 API 응답: 한국 도서 설명 (한글, 영문 포함)
  • 한글 문자: U+AC00~U+D7A3 범위 (모두 BMP 내, 서로게이트 페어 없음)
  • 이모지 포함 가능성: 극히 낮음 (도서 설명에 이모지 사용 드문)

결론:
원본 검토 의견은 기술적으로 유효하나, 한국 도서 설명에 대해서는 실제 발생 가능성이 매우 낮습니다. 현재 코드는 한글, 영문, 대부분의 공통 유니코드 범위에서 안전합니다.

이모지 또는 비-BMP 문자를 지원해야 할 필요가 생기면 Character.codePointCount() / offsetByCodePoints() 사용으로 개선할 수 있습니다. 현 단계에서는 코드 작동에 문제가 없습니다.


74-74: 검토 의견이 부정확합니다. 데이터베이스 컬럼이 바이트 단위가 아닌 문자 단위로 제약되어 있습니다.

BookJpaEntity.java의 description 필드는 @Column(length = 3000)으로 정의되어 있습니다. JPA의 length 속성은 문자 단위이며, 현대의 MySQL VARCHAR도 문자 단위로 길이를 제한합니다. 따라서 코드의 String.length() > 3000 체크는 데이터베이스 컬럼 제약과 완벽하게 일치합니다. UTF-8mb4 인코딩도 이를 변경하지 않습니다.

Likely an incorrect or invalid review comment.

@github-actions
Copy link

github-actions bot commented Oct 19, 2025

Test Results

486 tests   486 ✅  47s ⏱️
145 suites    0 💤
145 files      0 ❌

Results for commit 7632374.

♻️ This comment has been updated with latest results.

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/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (1)

74-74: 선택적 개선: 접미사를 상수로 정의하면 유지보수성이 향상됩니다.

"..." 문자열을 인라인으로 사용하는 대신 클래스 상수로 정의하면 향후 변경이나 재사용이 용이합니다.

다음 diff를 적용하여 접미사를 상수로 추출하세요:

 public class NaverBookXmlParser {
     private static final int MAX_DESCRIPTION_LENGTH = 3000;
+    private static final String TRUNCATION_SUFFIX = "...";

     public static NaverBookParseResult parseBookList(String xml) {

그리고 사용 부분을 수정하세요:

                 String rawDescription =  StringEscapeUtils.unescapeHtml4(getTagValue(item, "description"));
                 String description;
-                String suffix = "...";
-                if (rawDescription.length() > MAX_DESCRIPTION_LENGTH) {
-                    description = rawDescription.substring(0, MAX_DESCRIPTION_LENGTH - suffix.length()) + suffix;
+                if (rawDescription.length() > MAX_DESCRIPTION_LENGTH) {
+                    description = rawDescription.substring(0, MAX_DESCRIPTION_LENGTH - TRUNCATION_SUFFIX.length()) + TRUNCATION_SUFFIX;
                 } else {
                     description = rawDescription;
                 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 32d9b1b and 2166a8f.

📒 Files selected for processing (1)
  • src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (2 hunks)
🔇 Additional comments (3)
src/main/java/konkuk/thip/book/adapter/out/api/naver/NaverBookXmlParser.java (3)

19-19: 구현 로직이 정확합니다.

HTML 언이스케이프 후 문자 길이를 확인하고 3000자를 초과하면 2997자로 자르고 "..."를 추가하는 로직이 올바르게 구현되었습니다. 최종적으로 정확히 3000자가 되도록 처리되며, NPE 위험도 없습니다.

Also applies to: 72-79


72-79: 데이터베이스 스키마 검증 결과: 원래 리뷰 코멘트의 우려는 근거가 없습니다.

코드베이스 확인 결과:

  • BookJpaEntity.java 39번 줄: @Column(length = 3000) 정의
  • JPA/Hibernate의 @Column(length=N)은 기본적으로 문자 단위의 길이를 나타냅니다
  • 코드의 String.length()는 문자 수를 반환하며, 이는 데이터베이스 컬럼 정의와 일치합니다
  • 이는 표준 JPA/Hibernate 동작이며, MySQL, PostgreSQL, Oracle 등 대부분의 데이터베이스에서 문자 기반으로 동작합니다

따라서 현재 코드의 문자 기반 길이 제한은 데이터베이스 스키마와 올바르게 정렬되어 있습니다. 바이트 기반 VARCHAR 설정(예: Oracle VARCHAR(3000) BYTE)은 적용되지 않습니다.

Likely an incorrect or invalid review comment.


67-71: 제목, ISBN을 제외한 author, publisher 필드에만 길이 제한 필요

코드베이스를 검토한 결과, titleisbn은 이미 BookJpaEntity에서 길이 제약이 설정되어 있습니다 (각각 100, 13). 하지만 authorNamepublisher 필드는 @column 어노테이션이 없어 길이 제한이 없으며, 이 필드들이 Naver API로부터 직접 전달되어 데이터베이스에 저장될 때 제약 위반이 발생할 수 있습니다.

특히 description이 이미 파서 단계에서 3000자로 절단되는 패턴을 따르고 있으므로, authorNamepublisher도 동일한 방식으로 길이 제한을 적용하거나 절단 처리가 필요한지 검토해 주세요. 또한 HTML 언이스케이프는 일반적으로 문자열을 단축시키므로 (예: "<" → "<"), 이 부분은 추가 고려가 필요하지 않습니다.

seongjunnoh
seongjunnoh previously approved these changes Oct 20, 2025
Copy link
Collaborator

@seongjunnoh seongjunnoh left a comment

Choose a reason for hiding this comment

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

수정하신 부분 확인했습니다! 기존에 관련 테스트 코드가 없어서 실제 데이터로 확인해주셨군요

Comment on lines 75 to 79
if (rawDescription.length() > MAX_DESCRIPTION_LENGTH) {
description = rawDescription.substring(0, MAX_DESCRIPTION_LENGTH - suffix.length()) + suffix;
} else {
description = rawDescription;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

확인했습니다!!

Copy link
Contributor

Choose a reason for hiding this comment

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

확인했슴다~

buzz0331
buzz0331 previously approved these changes Oct 20, 2025
Copy link
Contributor

@buzz0331 buzz0331 left a comment

Choose a reason for hiding this comment

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

늦어서 죄송합니다 🙏🏻 확인했습니다~

범망경보살계본사기 좀 무섭네여

Comment on lines 75 to 79
if (rawDescription.length() > MAX_DESCRIPTION_LENGTH) {
description = rawDescription.substring(0, MAX_DESCRIPTION_LENGTH - suffix.length()) + suffix;
} else {
description = rawDescription;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

확인했슴다~

String description = StringEscapeUtils.unescapeHtml4(getTagValue(item, "description"));
String rawDescription = StringEscapeUtils.unescapeHtml4(getTagValue(item, "description"));
String description;
String suffix = "...";
Copy link
Contributor

Choose a reason for hiding this comment

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

p3: 이것도 static final로 빼도 되지 않을까여??

Copy link
Member Author

Choose a reason for hiding this comment

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

옷 넵!!

@hd0rable hd0rable dismissed stale reviews from buzz0331 and seongjunnoh via 7632374 October 20, 2025 05:37
@hd0rable hd0rable merged commit 7c65945 into develop Oct 20, 2025
4 checks passed
@hd0rable hd0rable deleted the hotfix/#327-book-description-3000 branch October 22, 2025 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[THIP2025-372] [hotfix] 책 설명 3000자 넘을경우 자르고 ...추가해서 db 저장하도록 수정

4 participants