From d3a2b9fae070cf0148dce322a367a7ba6e24a418 Mon Sep 17 00:00:00 2001 From: Tomaz Bratanic Date: Fri, 12 Jul 2024 12:39:29 +0200 Subject: [PATCH] Fix neo4j type error on missing constraint information (#24177) If you use `refresh_schema=False`, then the metadata constraint doesn't exist. ATM, we used default `None` in the constraint check, but then `any` fails because it can't iterate over None value --- libs/community/langchain_community/graphs/neo4j_graph.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/graphs/neo4j_graph.py b/libs/community/langchain_community/graphs/neo4j_graph.py index 4897348a7b9..55c03005d9a 100644 --- a/libs/community/langchain_community/graphs/neo4j_graph.py +++ b/libs/community/langchain_community/graphs/neo4j_graph.py @@ -555,10 +555,11 @@ class Neo4jGraph(GraphStore): el["labelsOrTypes"] == [BASE_ENTITY_LABEL] and el["properties"] == ["id"] for el in self.structured_schema.get("metadata", {}).get( - "constraint" + "constraint", [] ) ] ) + if not constraint_exists: # Create constraint self.query(