feat: add conflict handling for document deletion and selection based on processing state

This commit is contained in:
Anish Sarkar 2026-02-05 22:16:23 +05:30
parent aef59d04eb
commit 6cd3f5c1f6
4 changed files with 51 additions and 14 deletions

View file

@ -230,6 +230,14 @@ async def delete_note(
if not document:
raise HTTPException(status_code=404, detail="Note not found")
# Check if note is pending or currently being processed
doc_state = document.status.get("state") if document.status else None
if doc_state in ("pending", "processing"):
raise HTTPException(
status_code=409,
detail="Cannot delete note while it is pending or being processed. Please wait for processing to complete.",
)
# Delete document (chunks will be cascade deleted)
await session.delete(document)
await session.commit()