iflytek/astron-agent · error · CustomException
ChunkDeleteFailed
ChunkDeleteFailed
Error message
Deletion failed: {error_msg} What it means
chunks_delete reached RAGFlow successfully but RAGFlow returned a non-success response for the delete operation. The strategy extracts response['message'] (default 'Deletion failed') and raises CustomException with ChunkDeleteFailed prefixed by 'Deletion failed:'. This is an application-level failure reported by the RAGFlow API, not a transport exception.
Solutions
- Inspect the message after 'Deletion failed:' — it is RAGFlow's own error text and usually names the offending chunk or reason.
- Verify docId and chunkIds still exist via query_doc before deleting; refresh stale IDs.
- Confirm the dataset_id used to build the RAGFlow request matches the document's actual dataset.
- Treat 'not found' style messages as idempotent success if your workflow allows concurrent deletes.
Example fix
// before
await strategy.chunks_delete(docId, chunk_ids)
// after
try:
await strategy.chunks_delete(docId, chunk_ids)
except CustomException as e:
if "not found" in str(e).lower():
logger.warning("Chunks already gone, treating as success")
else:
raise Defensive patterns
Strategy: try-catch
Validate before calling
existing = await strategy.query_doc(docId)
existing_ids = {c["id"] for c in existing}
deletable = [cid for cid in chunk_ids if cid in existing_ids] Type guard
null
Try / catch
try:
await strategy.chunks_delete(docId, chunk_ids)
except CustomException as e:
if e.code == CodeEnum.ChunkDeleteFailed and "not found" in str(e).lower():
logger.warning("Chunks already deleted: %s", e)
else:
raise Prevention
- Refresh chunk IDs via query_doc before deleting; never cache chunk IDs across sessions.
- Treat not-found deletes as idempotent success in concurrent workflows.
- Verify dataset_id/docId pairing matches RAGFlow's actual layout.
When it happens
Trigger: RAGFlow delete-chunk API returns code != 0 — e.g. chunk already deleted, chunk ID not found in the dataset/document, wrong dataset_id/docId pairing, or RAGFlow-side permission/validation rejection.
Common situations: Stale chunk IDs in the UI after someone else deleted the chunk; document recreated so chunk IDs no longer match; RAGFlow dataset permissions changed.
Related errors
- REPO_FILE_DELETE_FAILED
- REPO_KNOWLEDGE_DELETE_FAILED
- fetch_all_document_chunks failed on page
- RAGFLOW_RAGError
- OPERATION_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/2b4443a7a136bf32.
Report an issue: GitHub.
Appendix: source
Thrown at core/knowledge/service/impl/ragflow_strategy.py:1059
logger.info(f"Using dataset: {dataset_id}")
# 2. Call RAGFlow deletion API directly
delete_response = await ragflow_client.delete_chunks(
dataset_id=dataset_id, document_id=docId, chunk_ids=chunkIds
)
logger.info(f"RAGFlow chunk deletion response: {delete_response}")
# 3. Process response
if delete_response.get("code") == 0:
logger.info(f"Successfully deleted {len(chunkIds)} chunks")
return None # Success, let API layer handle the response
else:
# RAGFlow deletion failed
error_msg = delete_response.get("message", "Deletion failed")
logger.error(f"RAGFlow deletion failed: {error_msg}")
raise CustomException(
CodeEnum.ChunkDeleteFailed, f"Deletion failed: {error_msg}"
)
except CustomException:
raise # Re-raise custom exceptions
except Exception as e:
logger.error(f"Chunk deletion operation failed: {e}")
raise CustomException(
CodeEnum.ChunkDeleteFailed, f"Deletion operation failed: {str(e)}"
)
async def query_doc(self, docId: str, **kwargs: Any) -> List[Dict[str, Any]]:
"""Query all chunk information for a document using RAGFlow."""
try:
logger.info(f"Starting document chunk query: docId={docId}")
dataset_id = await self._resolve_dataset_id(kwargs.get(_DATASET_ID_KWARG))
if not dataset_id:View on GitHub (pinned to 5e758547a8)