OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
fix: cancel case not retryable (#1771)
Wallgauc133e5275c7b
diff --git a/frontend/app/api/queries/useGetTasksQuery.ts b/frontend/app/api/queries/useGetTasksQuery.tsindex ca874e44a..a154127c8 100644--- a/frontend/app/api/queries/useGetTasksQuery.ts+++ b/frontend/app/api/queries/useGetTasksQuery.ts@@ -18,6 +18,7 @@ export type TaskFailurePhase =| "embedding"| "indexing"| "file_validation"+ | "cancelled"| "unknown";/** Who can resolve the failure (enhanced API). */diff --git a/frontend/lib/task-error-display.ts b/frontend/lib/task-error-display.tsindex 0dd2b8fb4..7c19f2bce 100644--- a/frontend/lib/task-error-display.ts+++ b/frontend/lib/task-error-display.ts@@ -18,6 +18,7 @@ export type TaskPipelineStepId =| "embedding"| "indexing"| "file_validation"+ | "cancelled"| "unknown";export interface IngestionPipelineStep {@@ -50,6 +51,7 @@ const PIPELINE_STEP_LABELS: Record<TaskPipelineStepId, string> = {embedding: "Embedding",indexing: "Indexing",file_validation: "File validation",+ cancelled: "Cancelled",unknown: "Ingestion",};@@ -93,6 +95,9 @@ export function normalizeFailurePhase(}export function buildRowStatusLabel(failedStep: TaskPipelineStepId): string {+ if (failedStep === "cancelled") {+ return "Cancelled";+ }if (failedStep === "file_validation") {return "File validation issue";}@@ -103,13 +108,20 @@ export function buildRowStatusLabel(failedStep: TaskPipelineStepId): string {}export function buildFailureSummary(failedStep: TaskPipelineStepId): string {+ if (failedStep === "cancelled") {+ return "Cancelled";+ }return `Failed at ${PIPELINE_STEP_LABELS[failedStep].toLowerCase()}`;}export function buildPipelineStepsFromFailurePhase(failurePhase: TaskPipelineStepId,): IngestionPipelineStep[] {- if (failurePhase === "file_validation" || failurePhase === "unknown") {+ if (+ failurePhase === "file_validation" ||+ failurePhase === "cancelled" ||+ failurePhase === "unknown"+ ) {return [{id: failurePhase,diff --git a/src/services/task_service.py b/src/services/task_service.pyindex d633aac47..d924b418d 100644--- a/src/services/task_service.py+++ b/src/services/task_service.py@@ -69,6 +69,17 @@ def _is_non_retryable_file_error(error: str) -> bool:return any(marker in lowered for marker in _NON_RETRYABLE_FILE_ERROR_MARKERS)+_TASK_CANCELLATION_ERROR_MARKERS = (+ "task cancelled by user",+ "file processing task cancelled",+)+++def _is_task_cancellation_error(error: str) -> bool:+ lowered = error.lower()+ return any(marker in lowered for marker in _TASK_CANCELLATION_ERROR_MARKERS)++def _is_transient_connectivity_error(error: str) -> bool:lowered = error.lower()return any(marker in lowered for marker in _TRANSIENT_CONNECTIVITY_ERROR_MARKERS)@@ -927,6 +938,13 @@ class TaskService:phase = file_task.phaseerror = file_task.error or ""+ if _is_task_cancellation_error(error):+ return {+ "failure_phase": "cancelled",+ "user_facing_message": "Ingestion was cancelled.",+ "actionable_by": "USER_ACTIONABLE",+ }+if docling_status == DoclingPhaseStatus.EXPIRED:return {"component": "docling",diff --git a/tests/unit/test_task_service_get_task_status2.py b/tests/unit/test_task_service_get_task_status2.pyindex 8d7a4c082..64660959f 100644--- a/tests/unit/test_task_service_get_task_status2.py+++ b/tests/unit/test_task_service_get_task_status2.py@@ -145,6 +145,19 @@ class TestInferFailureMetadata:assert meta["failure_phase"] == "parsing"assert meta["actionable_by"] == "RETRYABLE"+ def test_task_cancelled_by_user_not_retryable(self, task_service):+ ft = _make_file_task(+ phase=IngestionPhase.DOCLING,+ docling_status=DoclingPhaseStatus.PROCESSING,+ error="Task cancelled by user",+ )+ meta = task_service._infer_failure_metadata(ft)+ assert meta is not None+ assert "component" not in meta+ assert meta["failure_phase"] == "cancelled"+ assert meta["actionable_by"] == "USER_ACTIONABLE"+ assert meta["user_facing_message"] == "Ingestion was cancelled."+def test_langflow_phase_failure(self, task_service):ft = _make_file_task(phase=IngestionPhase.LANGFLOW,diff --git a/tests/unit/test_task_service_retry_failed_files.py b/tests/unit/test_task_service_retry_failed_files.pyindex 849d41f09..09cab685e 100644--- a/tests/unit/test_task_service_retry_failed_files.py+++ b/tests/unit/test_task_service_retry_failed_files.py@@ -34,6 +34,32 @@ def _store_task(task_service.task_store.setdefault(user_id, {})[upload_task.task_id] = upload_task+async def test_retry_skips_cancelled_files(task_service):+ processor = Mock()+ ft = FileTask(file_path="/data/cancelled.pdf", filename="cancelled.pdf")+ ft.status = TaskStatus.FAILED+ ft.phase = IngestionPhase.DOCLING+ ft.docling_status = DoclingPhaseStatus.PROCESSING+ ft.error = "Task cancelled by user"+ task = UploadTask(+ task_id="task-cancelled",+ total_files=1,+ file_tasks={"/data/cancelled.pdf": ft},+ status=TaskStatus.FAILED,+ failed_files=1,+ processor=processor,+ )+ _store_task(task_service, "user1", task)++ with patch("os.path.isfile", return_value=True):+ result = await task_service.retry_failed_files("user1", "task-cancelled")++ assert result["retried"] == 0+ assert result["status"] == "no_op"+ assert result["skipped"][0]["reason"] == "not_retryable"++@pytest.mark.asyncioasync def test_retry_all_failed_retryable_files(task_service):processor = Mock()