[Hotfix] HWP→PDF 변환 실패 수정 (사이냅 SDK 출력 파일명 미스매치)#198
Conversation
사이냅 PDF SDK는 입력 파일명에 .pdf를 덧붙여 출력하지만
(Document.hwp → Document.hwp.pdf) Python 코드는 with_suffix('.pdf')로
.hwp를 교체한 경로(Document.pdf)를 기대 → 모든 HWP 파일이
'PDF 변환 실패'로 잘못 분류되는 회귀.
수정 범위 — facade 3개 동일 적용:
- intelligent_processor.py
- attachment_processor.py
- convert_processor.py
변경:
- SDK 출력을 임시 디렉토리로 받고 glob으로 PDF 회수 후 의도한 위치로 copy
- 진단 로그 보강 (preflight, returncode, stdout, stderr, produced_files)
- 600초 타임아웃 추가
- intelligent_processor: SDK 실패 시 LibreOffice 폴백 추가
운영 검증:
컨테이너에 핫리로드 후 Document-104920.hwp 재처리 86.84초 성공
(returncode=0 produced_files=['Document-104920.hwp.pdf']
→ /nfs-root/docs/Document-104920.pdf)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
📝 WalkthroughWalkthroughThree processor modules ( ChangesPDF-SDK Conversion with Temporary Output and Fallback
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
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)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
genon/preprocessor/facade/intelligent_processor.py (1)
1760-1770:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winLGTM — SDK→LibreOffice fallback is correctly gated.
The retry only triggers when the original attempt used the SDK (
use_sdkis True), which is the right call: if the caller explicitly passeduse_pdf_sdk=False, silently re-trying with another engine would violate that intent. Thenot converted or not os.path.exists(converted)check also catches the "SDK returned a path that vanished" failure mode in addition to outrightNonereturns.Minor nit on line 1765 only: the warning string has no interpolation, so the
fprefix is unnecessary (Ruff F541).🧹 Suggested cleanup
- _log.warning(f"[intelligent] SDK conversion failed → fallback to LibreOffice") + _log.warning("[intelligent] SDK conversion failed → fallback to LibreOffice")🤖 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 `@genon/preprocessor/facade/intelligent_processor.py` around lines 1760 - 1770, The warning message in the intelligent preprocessing flow uses an unnecessary f-string: in the block inside intelligent_processor where use_sdk is determined and convert_to_pdf is called (symbols: convert_to_pdf, use_sdk, _log.warning), remove the f-prefix from the literal "_log.warning(f\"[intelligent] SDK conversion failed → fallback to LibreOffice\")" (or alternatively add interpolation fields if you intend to format), so change it to a plain string `_log.warning("[intelligent] SDK conversion failed → fallback to LibreOffice")`.
🧹 Nitpick comments (1)
genon/preprocessor/facade/attachment_processor.py (1)
113-203: 💤 Low valueLGTM — same SDK fix as
convert_processor.py; behavior is consistent across facades.Same correctness assessment applies: temp-dir output + copy-to-target cleanly fixes the
Document.hwp.pdfvsDocument.pdfmismatch, and cleanup/logging are sound.One maintainability note: this
_convert_to_pdf_sdkis now byte-for-byte identical in three facades. The reason (Genos web UI loading each facade as a single file) is documented only inintelligent_processor.py:17-19. Consider duplicating that short rationale comment here and inconvert_processor.pyso future readers don't try to extract a shared helper without realizing it would break the runtime loader.🤖 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 `@genon/preprocessor/facade/attachment_processor.py` around lines 113 - 203, The function _convert_to_pdf_sdk is byte-for-byte duplicated across facades; add the same short rationale comment that exists in intelligent_processor.py (lines 17-19) to the top of this function in attachment_processor.py and also add that same comment to convert_processor.py so future maintainers know the duplication is intentional due to the Genos web UI loading each facade as a single file; place the comment immediately above the _convert_to_pdf_sdk definition to make the reason obvious when someone considers extracting a shared helper.
🤖 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.
Outside diff comments:
In `@genon/preprocessor/facade/intelligent_processor.py`:
- Around line 1760-1770: The warning message in the intelligent preprocessing
flow uses an unnecessary f-string: in the block inside intelligent_processor
where use_sdk is determined and convert_to_pdf is called (symbols:
convert_to_pdf, use_sdk, _log.warning), remove the f-prefix from the literal
"_log.warning(f\"[intelligent] SDK conversion failed → fallback to
LibreOffice\")" (or alternatively add interpolation fields if you intend to
format), so change it to a plain string `_log.warning("[intelligent] SDK
conversion failed → fallback to LibreOffice")`.
---
Nitpick comments:
In `@genon/preprocessor/facade/attachment_processor.py`:
- Around line 113-203: The function _convert_to_pdf_sdk is byte-for-byte
duplicated across facades; add the same short rationale comment that exists in
intelligent_processor.py (lines 17-19) to the top of this function in
attachment_processor.py and also add that same comment to convert_processor.py
so future maintainers know the duplication is intentional due to the Genos web
UI loading each facade as a single file; place the comment immediately above the
_convert_to_pdf_sdk definition to make the reason obvious when someone considers
extracting a shared helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b59a5a61-93d5-4f1b-8400-11abc61572cd
📒 Files selected for processing (3)
genon/preprocessor/facade/attachment_processor.pygenon/preprocessor/facade/convert_processor.pygenon/preprocessor/facade/intelligent_processor.py
요약
2.0.0.3 배포 직후 발생한 HWP 파일 처리 100% 실패 핫픽스.
원인
_convert_to_pdf_sdk가 사이냅 PDF SDK 출력 파일명을 잘못 추측:Document-104918.hwpDocument-104918.hwp.pdfDocument-104918.pdf코드:
pdf_path = in_path.with_suffix('.pdf')로.hwp를.pdf로 교체 가정.실제 SDK: 입력 풀네임에
.pdf를 덧붙임.→
pdf_path.exists()항상 False → 모든 HWP 가GenosServiceException(1, "PDF 변환 실패")로 강제 실패.운영 컨테이너에서
pdfConverter직접 실행으로 SDK 자체는 정상 (returncode=0, PDF 5MB 생성) 확인 — 순전히 호출 측 버그.수정
_convert_to_pdf_sdk를 세 facade 에서 동일하게 수정:/tmp/pdfsdk_out_*/) — 출력 파일명 추측에 의존하지 않고, NFS 쓰기 권한 의존도 제거<basename>.pdf) 로shutil.copy2— 다운스트림 호환 유지cmd,returncode,stdout,stderr,produced_files모두 기록 (이전엔 stderr 일부만)intelligent_processor.__call__에 SDK 실패 시 LibreOffice 폴백 추가 (방어선)검증
운영 컨테이너에 웹 UI 핫리로드로 적용 후
Document-104920.hwp재처리 → 성공:변경 파일
genon/preprocessor/facade/intelligent_processor.pygenon/preprocessor/facade/attachment_processor.pygenon/preprocessor/facade/convert_processor.pyTest plan
returncode,produced_files정상 기록 확인긴급도
P0 — 2.0.0.3 머지된 상태에서 운영의 모든 HWP 파일 처리 막힘. 운영은 웹 UI 핫리로드로 임시 적용 중 (컨테이너 재시작 시 휘발). 이 PR 머지로 GitHub source-of-truth 와 운영 코드 동기화.
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes