Skip to content

Commit

Permalink
improve error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
epinzur committed Oct 15, 2024
1 parent a0c20d4 commit 26e4475
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions libs/astradb/langchain_astradb/graph_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 26e4475

Please sign in to comment.