mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-30 00:32:30 +08:00
Fix (sdk): ensure variables defined in rm_chunk API (#12274)
### What problem does this PR solve? Fixes a bug in the `rm_chunk` SDK interface where an `UnboundLocalError` could occur if `chunk_ids` is not provided in the request. - `unique_chunk_ids` and `duplicate_messages` are now always initialized in the `else` branch when `chunk_ids` is missing. - API behavior remains unchanged when `chunk_ids` is present. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1286,6 +1286,9 @@ async def rm_chunk(tenant_id, dataset_id, document_id):
|
||||
if "chunk_ids" in req:
|
||||
unique_chunk_ids, duplicate_messages = check_duplicate_ids(req["chunk_ids"], "chunk")
|
||||
condition["id"] = unique_chunk_ids
|
||||
else:
|
||||
unique_chunk_ids = []
|
||||
duplicate_messages = []
|
||||
chunk_number = settings.docStoreConn.delete(condition, search.index_name(tenant_id), dataset_id)
|
||||
if chunk_number != 0:
|
||||
DocumentService.decrement_chunk_num(document_id, dataset_id, 1, chunk_number, 0)
|
||||
|
||||
Reference in New Issue
Block a user