mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-01 08:15:44 +08:00
## What problem does this PR solve? Closes #15874 Both the `POST /api/v1/datasets/<dataset_id>/chunks` (re-parse) and `DELETE /api/v1/datasets/<dataset_id>/chunks` (stop-parsing) handlers called `settings.docStoreConn.delete` unconditionally. When the tenant/dataset index has not been created yet — fresh dataset, first parse interrupted before any chunks were indexed, or index manually removed — the delete call throws and the handler returns HTTP 500 **after** the document state was already mutated (RUNNING with zeroed counters for the parse path; CANCEL with zeroed counters for the stop path), leaving the document in an inconsistent state. The newer `parse_documents` path in `document_api.py` already uses `index_exist` before deleting: ## How to fix? Apply the same `index_exist` guard to both call sites in `chunk_api.py`: - **`parse`** (POST path, line ~192): guard the delete before `TaskService.filter_delete`. - **`stop_parsing`** (DELETE path, line ~242): guard the delete after `DocumentService.update_by_id`. Both sites already have the correct `search.index_name(tenant_id)` and `dataset_id` parameters; the guard is a one-line addition at each site. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Wang Qi <wangq8@outlook.com>