From 8cf10fa460e89dc794f6606b822002f7bc09d0b0 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Sun, 14 Jul 2024 06:54:01 -0700 Subject: [PATCH] Specific error when updating state as an unknown node (#1015) --- libs/langgraph/langgraph/pregel/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/langgraph/langgraph/pregel/__init__.py b/libs/langgraph/langgraph/pregel/__init__.py index f1d95c509..05d99d8d0 100644 --- a/libs/langgraph/langgraph/pregel/__init__.py +++ b/libs/langgraph/langgraph/pregel/__init__.py @@ -555,6 +555,8 @@ class Pregel( as_node = last_seen_by_node[-1][1] if as_node is None: raise InvalidUpdateError("Ambiguous update, specify as_node") + if as_node not in self.nodes: + raise InvalidUpdateError(f"Node {as_node} does not exist") # update channels with ChannelsManager(self.channels, checkpoint, config) as channels: # create task to run all writers of the chosen node @@ -644,6 +646,8 @@ class Pregel( as_node = last_seen_by_node[-1][1] if as_node is None: raise InvalidUpdateError("Ambiguous update, specify as_node") + if as_node not in self.nodes: + raise InvalidUpdateError(f"Node {as_node} does not exist") # update channels, acting as the chosen node async with AsyncChannelsManager(self.channels, checkpoint, config) as channels: # create task to run all writers of the chosen node