Skip to content

Commit ac2e024

Browse files
committed
fix: re-raise exception in ingest_document so Celery retry mechanism fires (#561)
1 parent 4f95ffb commit ac2e024

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

backend/app/services/document_ingestion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,6 @@ def ingest_document(document_id: str, filepath: str, original_name: str, user_id
171171
db.commit()
172172
except Exception:
173173
logger.exception("Failed to mark document %s as failed", document_id)
174+
raise
174175
finally:
175176
db.close()

backend/app/tasks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def process_document(
4141
original_name=original_name,
4242
user_id=user_id,
4343
)
44-
return {"document_id": document_id, "status": "completed"}
44+
with get_db_session() as db:
45+
doc = db.query(Document).filter(Document.id == document_id).first()
46+
status = doc.status if doc else "unknown"
47+
return {"document_id": document_id, "status": status}
4548
except Exception as exc:
4649
logger.error("Document %s processing failed (attempt %s): %s", document_id, self.request.retries + 1, exc)
4750
with get_db_session() as db:

0 commit comments

Comments
 (0)