From bf1cd68f64a3789804e57c77b2c0bcc2ff001546 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Wed, 13 May 2026 12:18:53 +0300 Subject: [PATCH] Preserve cause chain on docling wrapper exceptions --- .../haiku/rag/converters/docling_local.py | 2 +- .../haiku/rag/converters/docling_serve.py | 2 +- .../haiku/rag/providers/docling_serve.py | 20 +++++++++---------- uv.lock | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/haiku_rag_slim/haiku/rag/converters/docling_local.py b/haiku_rag_slim/haiku/rag/converters/docling_local.py index 3028b59c..5449694b 100644 --- a/haiku_rag_slim/haiku/rag/converters/docling_local.py +++ b/haiku_rag_slim/haiku/rag/converters/docling_local.py @@ -311,7 +311,7 @@ class DoclingLocalConverter(DocumentConverter): self._sync_convert_docling_text, text, doc_name, source_uri ) except Exception as e: - raise ValueError(f"Failed to convert text to DoclingDocument: {e}") + raise ValueError(f"Failed to convert text to DoclingDocument: {e}") from e def _sync_convert_docling_text( self, text: str, doc_name: str, source_uri: str | None = None diff --git a/haiku_rag_slim/haiku/rag/converters/docling_serve.py b/haiku_rag_slim/haiku/rag/converters/docling_serve.py index 68b6876a..e8e6237c 100644 --- a/haiku_rag_slim/haiku/rag/converters/docling_serve.py +++ b/haiku_rag_slim/haiku/rag/converters/docling_serve.py @@ -253,7 +253,7 @@ class DoclingServeConverter(DocumentConverter): ) return await self.convert_text(prepared_content, name=f"{path.stem}.md") except Exception as e: - raise ValueError(f"Failed to read text file {path}: {e}") + raise ValueError(f"Failed to read text file {path}: {e}") from e def read_file(): with open(path, "rb") as f: diff --git a/haiku_rag_slim/haiku/rag/providers/docling_serve.py b/haiku_rag_slim/haiku/rag/providers/docling_serve.py index db96a07d..3345fed9 100644 --- a/haiku_rag_slim/haiku/rag/providers/docling_serve.py +++ b/haiku_rag_slim/haiku/rag/providers/docling_serve.py @@ -103,21 +103,21 @@ class DoclingServeClient: raise ValueError( f"Could not connect to docling-serve at {self.base_url}. " f"Ensure the service is running and accessible. Error: {e}" - ) + ) from e except httpx.TimeoutException as e: raise ValueError( f"Request to docling-serve timed out after {self.timeout}s. Error: {e}" - ) + ) from e except httpx.HTTPStatusError as e: if e.response.status_code == 401: raise ValueError( "Authentication failed. Check your API key configuration." - ) - raise ValueError(f"HTTP error from docling-serve: {e}") + ) from e + raise ValueError(f"HTTP error from docling-serve: {e}") from e except ValueError: raise except Exception as e: - raise ValueError(f"Failed to process via docling-serve: {e}") + raise ValueError(f"Failed to process via docling-serve: {e}") from e async def submit_and_poll_zip( self, @@ -149,18 +149,18 @@ class DoclingServeClient: raise ValueError( f"Could not connect to docling-serve at {self.base_url}. " f"Ensure the service is running and accessible. Error: {e}" - ) + ) from e except httpx.TimeoutException as e: raise ValueError( f"Request to docling-serve timed out after {self.timeout}s. Error: {e}" - ) + ) from e except httpx.HTTPStatusError as e: if e.response.status_code == 401: raise ValueError( "Authentication failed. Check your API key configuration." - ) - raise ValueError(f"HTTP error from docling-serve: {e}") + ) from e + raise ValueError(f"HTTP error from docling-serve: {e}") from e except ValueError: raise except Exception as e: - raise ValueError(f"Failed to process via docling-serve: {e}") + raise ValueError(f"Failed to process via docling-serve: {e}") from e diff --git a/uv.lock b/uv.lock index cf73fe76..5e1cca44 100644 --- a/uv.lock +++ b/uv.lock @@ -1474,7 +1474,7 @@ dev = [ requires-dist = [ { name = "haiku-rag-slim", extras = ["docling", "voyageai", "mxbai", "cohere", "zeroentropy", "tui"], editable = "haiku_rag_slim" }, { name = "haiku-rag-slim", extras = ["s3"], marker = "extra == 's3'", editable = "haiku_rag_slim" }, - { name = "textual", marker = "extra == 'tui'", specifier = ">=1.0.0" }, + { name = "textual", marker = "extra == 'tui'", specifier = ">=8.2.4" }, ] provides-extras = ["tui", "s3"] @@ -1621,7 +1621,7 @@ requires-dist = [ { name = "python-dotenv", specifier = ">=1.2.2" }, { name = "pyyaml", specifier = ">=6.0.3" }, { name = "rich", specifier = ">=14.3.3" }, - { name = "textual", marker = "extra == 'tui'", specifier = ">=8.2.1" }, + { name = "textual", marker = "extra == 'tui'", specifier = ">=8.2.4" }, { name = "textual-image", marker = "extra == 'tui'", specifier = ">=0.8.5" }, { name = "torch", marker = "extra == 'jina'", specifier = ">=2.0.0" }, { name = "transformers", marker = "extra == 'jina'", specifier = ">=4.40.0" }, @@ -4815,7 +4815,7 @@ wheels = [ [[package]] name = "textual" -version = "8.2.1" +version = "8.2.5" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markdown-it-py", extra = ["linkify"] }, @@ -4825,9 +4825,9 @@ dependencies = [ { name = "rich" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/4f/07/766ad19cf2b15cae2d79e0db46a1b783b62316e9ff3e058e7424b2a4398b/textual-8.2.1.tar.gz", hash = "sha256:4176890e9cd5c95dcdd206541b2956b0808e74c8c36381c88db53dcb45237451", size = 1848386, upload-time = "2026-03-29T03:57:32.242Z" } +sdist = { url = "https://files.pythonhosted.org/packages/62/1e/1eedc5bac184d00aaa5f9a99095f7e266af3ec46fa926c1051be5d358da1/textual-8.2.5.tar.gz", hash = "sha256:6c894e65a879dadb4f6cf46ddcfedb0173ff7e0cb1fe605ff7b357a597bdbc90", size = 1851596, upload-time = "2026-04-30T08:02:58.956Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/25/09/c6f000c2e3702036e593803319af02feee58a662528d0d5728a37e1cf81b/textual-8.2.1-py3-none-any.whl", hash = "sha256:746cbf947a8ca875afc09779ef38cadbc7b9f15ac886a5090f7099fef5ade990", size = 723871, upload-time = "2026-03-29T03:57:34.334Z" }, + { url = "https://files.pythonhosted.org/packages/cd/01/c4555f9c8a692ff83d84930150540f743ce94c89234f9e9a15ff4baba3a8/textual-8.2.5-py3-none-any.whl", hash = "sha256:247d2aa2faf222749c321f88a736247f37ee2c023604079c7490bfacddfcd4b2", size = 727050, upload-time = "2026-04-30T08:03:01.421Z" }, ] [[package]]