From b2b7ed892713760b335d81fd21dea3140a6ad102 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Tue, 25 Mar 2025 19:03:29 +0800 Subject: [PATCH] Fix: abnormal chunk id (#6506) ### What problem does this PR solve? #6500 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/doc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/apps/sdk/doc.py b/api/apps/sdk/doc.py index c393b862a..2d2668cd0 100644 --- a/api/apps/sdk/doc.py +++ b/api/apps/sdk/doc.py @@ -917,6 +917,8 @@ def list_chunks(tenant_id, dataset_id, document_id): res = {"total": 0, "chunks": [], "doc": renamed_doc} if req.get("id"): chunk = settings.docStoreConn.get(req.get("id"), search.index_name(tenant_id), [dataset_id]) + if not chunk: + return get_result(message=f"Chunk not found: {dataset_id}/{req.get('id')}", code=settings.RetCode.NOT_FOUND) k = [] for n in chunk.keys(): if re.search(r"(_vec$|_sm_|_tks|_ltks)", n):