diff --git a/libs/astradb/langchain_astradb/graph_vectorstores.py b/libs/astradb/langchain_astradb/graph_vectorstores.py index 69ebd44..322793d 100644 --- a/libs/astradb/langchain_astradb/graph_vectorstores.py +++ b/libs/astradb/langchain_astradb/graph_vectorstores.py @@ -342,14 +342,19 @@ def __init__( test_vs.metadata_search( filter={self.metadata_incoming_links_key: "test"}, n=1 ) - except BaseException as exp: + except ValueError as exp: # determine if error is because of a un-indexed column. Ref: # https://docs.datastax.com/en/astra-db-serverless/api-reference/collections.html#considerations-for-selective-indexing error_message = str(exp).lower() if ("unindexed filter path" in error_message) or ( "incompatible with the requested indexing policy" in error_message ): - msg = "The collection configuration is incompatible with vector graph store. Please create a new collection." # noqa: E501 + msg = ( + "The collection configuration is incompatible with vector graph " + "store. Please create a new collection and make sure the path " + f"`{self.metadata_incoming_links_key}` is not excluded by indexing." + ) + raise ValueError(msg) from exp raise exp # noqa: TRY201 diff --git a/libs/astradb/tests/integration_tests/test_upgrade_to_graphvectorstore.py b/libs/astradb/tests/integration_tests/test_upgrade_to_graphvectorstore.py index 5238f0b..3164513 100644 --- a/libs/astradb/tests/integration_tests/test_upgrade_to_graphvectorstore.py +++ b/libs/astradb/tests/integration_tests/test_upgrade_to_graphvectorstore.py @@ -232,7 +232,11 @@ def test_upgrade_to_gvs_failure_sync( assert v_doc is not None assert v_doc.page_content == doc_al.page_content - expected_msg = "The collection configuration is incompatible with vector graph store. Please create a new collection." # noqa: E501 + expected_msg = ( + "The collection configuration is incompatible with vector graph " + "store. Please create a new collection and make sure the path " + "`incoming_links` is not excluded by indexing." + ) with pytest.raises(ValueError, match=expected_msg): # Create a GRAPH Vector Store using the existing collection from above # with setup_mode=gvs_setup_mode and indexing_policy=gvs_indexing_policy @@ -294,7 +298,11 @@ async def test_upgrade_to_gvs_failure_async( assert v_doc is not None assert v_doc.page_content == doc_al.page_content - expected_msg = "The collection configuration is incompatible with vector graph store. Please create a new collection." # noqa: E501 + expected_msg = ( + "The collection configuration is incompatible with vector graph " + "store. Please create a new collection and make sure the path " + "`incoming_links` is not excluded by indexing." + ) with pytest.raises(ValueError, match=expected_msg): # Create a GRAPH Vector Store using the existing collection from above # with setup_mode=gvs_setup_mode and indexing_policy=gvs_indexing_policy