From 63b381ad680fd744a6e28996cd86d0c2ca3e5862 Mon Sep 17 00:00:00 2001 From: Kelvin Tan Date: Thu, 1 May 2025 08:49:51 -0700 Subject: [PATCH 1/2] Include the actual SQL exception when reporting the error. --- .../document_stores/pgvector/document_store.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py b/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py index 4cd08a6c9..16ed9c288 100644 --- a/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py +++ b/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py @@ -276,7 +276,7 @@ def _execute_sql( result = cursor.execute(sql_query, params) except Error as e: self._connection.rollback() - detailed_error_msg = f"{error_msg}.\nYou can find the SQL query and the parameters in the debug logs." + detailed_error_msg = f"{error_msg}: {e}.\nYou can find the SQL query and the parameters in the debug logs." raise DocumentStoreError(detailed_error_msg) from e return result @@ -314,7 +314,7 @@ async def _execute_sql_async( result = await cursor.execute(sql_query, params) except Error as e: await self._async_connection.rollback() - detailed_error_msg = f"{error_msg}.\nYou can find the SQL query and the parameters in the debug logs." + detailed_error_msg = f"{error_msg}: {e}.\nYou can find the SQL query and the parameters in the debug logs." raise DocumentStoreError(detailed_error_msg) from e return result @@ -795,7 +795,7 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D except Error as e: self._connection.rollback() error_msg = ( - "Could not write documents to PgvectorDocumentStore. \n" + "Could not write documents to PgvectorDocumentStore: {e}. \n" "You can find the SQL query and the parameters in the debug logs." ) raise DocumentStoreError(error_msg) from e @@ -852,7 +852,7 @@ async def write_documents_async( except Error as e: await self._async_connection.rollback() error_msg = ( - "Could not write documents to PgvectorDocumentStore. \n" + "Could not write documents to PgvectorDocumentStore: {e}. \n" "You can find the SQL query and the parameters in the debug logs." ) raise DocumentStoreError(error_msg) from e From 28a19ae347eea4aff6068f07c6de378567ada124 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Tue, 6 May 2025 17:33:52 +0200 Subject: [PATCH 2/2] small improvements --- README.md | 1 + .../document_stores/pgvector/document_store.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 34310df31..119b0200a 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ GitHub. The GitHub Actions workflow will take care of the rest. ``` 3. Wait for the CI to do its magic 4. Review the changelog PR + If the release is successful, the HaystackBot will open a pull request to generate the changelog. Add yourself as the reviewer. If there are any issues, edit the changelog manually. diff --git a/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py b/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py index 16ed9c288..5fcb664de 100644 --- a/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py +++ b/integrations/pgvector/src/haystack_integrations/document_stores/pgvector/document_store.py @@ -276,7 +276,9 @@ def _execute_sql( result = cursor.execute(sql_query, params) except Error as e: self._connection.rollback() - detailed_error_msg = f"{error_msg}: {e}.\nYou can find the SQL query and the parameters in the debug logs." + detailed_error_msg = ( + f"{error_msg}. Error: {e!r}. \nYou can find the SQL query and the parameters in the debug logs." + ) raise DocumentStoreError(detailed_error_msg) from e return result @@ -314,7 +316,9 @@ async def _execute_sql_async( result = await cursor.execute(sql_query, params) except Error as e: await self._async_connection.rollback() - detailed_error_msg = f"{error_msg}: {e}.\nYou can find the SQL query and the parameters in the debug logs." + detailed_error_msg = ( + f"{error_msg}. Error: {e!r}. \nYou can find the SQL query and the parameters in the debug logs." + ) raise DocumentStoreError(detailed_error_msg) from e return result @@ -795,7 +799,7 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D except Error as e: self._connection.rollback() error_msg = ( - "Could not write documents to PgvectorDocumentStore: {e}. \n" + f"Could not write documents to PgvectorDocumentStore. Error: {e!r}. \n" "You can find the SQL query and the parameters in the debug logs." ) raise DocumentStoreError(error_msg) from e @@ -852,7 +856,7 @@ async def write_documents_async( except Error as e: await self._async_connection.rollback() error_msg = ( - "Could not write documents to PgvectorDocumentStore: {e}. \n" + f"Could not write documents to PgvectorDocumentStore. Error: {e!r}. \n" "You can find the SQL query and the parameters in the debug logs." ) raise DocumentStoreError(error_msg) from e