From 7487739aec0c16ff121173e46a3c094528dc8649 Mon Sep 17 00:00:00 2001 From: hyungi Date: Mon, 29 Jun 2026 23:38:37 +0000 Subject: [PATCH] =?UTF-8?q?fix(clause-kb):=20=EC=A0=88-=EB=AC=B8=EC=84=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EB=B6=80=EB=AA=A8=20?= =?UTF-8?q?=ED=91=9C=EC=A4=80=20document=5Fimages=20=EB=A1=9C=20=ED=8F=B4?= =?UTF-8?q?=EB=B0=B1=20=ED=95=B4=EC=86=8C(docimg=20404=20=EC=88=98?= =?UTF-8?q?=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- app/api/documents.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/api/documents.py b/app/api/documents.py index f390738..ca01a8b 100644 --- a/app/api/documents.py +++ b/app/api/documents.py @@ -1048,6 +1048,19 @@ async def get_document_image_raw( DocumentImage.image_key == image_key, ) ) + if img is None: + # clause-KB: 절-문서는 부모 표준 이미지를 공유(md_content=부모 슬라이스) → parent_id 폴백. + from sqlalchemy import text as sql_text + _par = (await session.execute( + sql_text("SELECT parent_id FROM documents WHERE id = :id").bindparams(id=doc_id) + )).scalar() + if _par is not None: + img = await session.scalar( + select(DocumentImage).where( + DocumentImage.document_id == _par, + DocumentImage.image_key == image_key, + ) + ) if img is None: raise HTTPException(status_code=404, detail="이미지를 찾을 수 없습니다")