OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
fix: updated pdf password protected docling parsing error message with more actionable message (#2200)
Zephyrus0ab54a1402c5
diff --git a/src/services/task_service.py b/src/services/task_service.pyindex 13d1f64ea..aa60542c1 100644--- a/src/services/task_service.py+++ b/src/services/task_service.py@@ -988,6 +988,14 @@ class TaskService:"actionable_by": "USER_ACTIONABLE",}+ if "incorrect password" in error.lower(): # for password protected pdf cases+ return {+ "component": "docling",+ "failure_phase": "parsing",+ "user_facing_message": "This PDF is password-protected. Password-protected PDFs are not supported. Remove the password and upload the PDF again.",+ "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 159e194b0..1ae2bb850 100644--- a/tests/unit/test_task_service_get_task_status2.py+++ b/tests/unit/test_task_service_get_task_status2.py@@ -123,6 +123,32 @@ class TestInferFailureMetadata:assert meta is not Noneassert meta["actionable_by"] == "USER_ACTIONABLE"+ def test_password_protected_pdf_maps_to_clean_message(self, task_service):+ ft = _make_file_task(+ docling_status=DoclingPhaseStatus.FAILED,+ error=(+ "Docling conversion did not complete (failed): "+ "Docling result unavailable after SUCCESS status: Docling processing "+ "failed: docling-parse could not load document "+ "cbfc231c73e85df69b34cfa56b4bb0696dc0f10d0536bcca821f92c324041bac: "+ "Failed to load document (PDFium: Incorrect password error)."+ ),+ )+ meta = task_service._infer_failure_metadata(ft)+ assert meta is not None+ assert meta["actionable_by"] == "USER_ACTIONABLE"+ assert meta["component"] == "docling"+ assert meta["failure_phase"] == "parsing"+ msg = meta["user_facing_message"]+ assert "password-protected" in msg.lower()+ assert "not supported" in msg.lower()+ assert "remove the password" in msg.lower()+ assert "upload the pdf again" in msg.lower()+ # no internals leaked+ assert "pdfium" not in msg.lower()+ assert "docling-parse" not in msg.lower()+ assert "cbfc231c" not in msg+def test_langflow_empty_content_not_retryable(self, task_service):ft = _make_file_task(phase=IngestionPhase.LANGFLOW,