invoke-ai/InvokeAI · error · NodeNotFoundError
Edge source node {edge.source.node_id} does not exist in the
Error message
Edge source node {edge.source.node_id} does not exist in the graph What it means
NodeNotFoundError is raised when validating a graph and an edge's `source.node_id` does not exist as a key in the graph's nodes dict. Edges must connect two nodes present in the graph; a dangling source reference means the graph is invalid and cannot be executed.
Source
Thrown at invokeai/app/services/shared/graph.py:1810
pass
def _validate_unique_node_ids(self) -> None:
node_ids = [n.id for n in self.nodes.values()]
seen = set()
duplicate_node_ids = {nid for nid in node_ids if (nid in seen) or seen.add(nid)}
if duplicate_node_ids:
raise DuplicateNodeIdError(f"Node ids must be unique, found duplicates {duplicate_node_ids}")
def _validate_node_id_mapping(self) -> None:
for node_dict_id, node in self.nodes.items():
if node_dict_id != node.id:
raise NodeIdMismatchError(f"Node ids must match, got {node_dict_id} and {node.id}")
def _validate_edge_nodes_and_fields(self) -> None:
for edge in self.edges:
source_node = self.nodes.get(edge.source.node_id, None)
if source_node is None:
raise NodeNotFoundError(f"Edge source node {edge.source.node_id} does not exist in the graph")
destination_node = self.nodes.get(edge.destination.node_id, None)
if destination_node is None:
raise NodeNotFoundError(f"Edge destination node {edge.destination.node_id} does not exist in the graph")
if edge.source.field not in source_node.get_output_annotation().model_fields:
raise NodeFieldNotFoundError(
f"Edge source field {edge.source.field} does not exist in node {edge.source.node_id}"
)
if edge.destination.field not in type(destination_node).model_fields:
if isinstance(destination_node, CallSavedWorkflowInvocation) and is_call_saved_workflow_dynamic_input(
edge.destination.field
):
continue
raise NodeFieldNotFoundError(
f"Edge destination field {edge.destination.field} does not exist in node {edge.destination.node_id}"
)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Add the missing source node to the graph before/along with the edge
- Delete the dangling edge referencing the removed node
- Update the edge's source.node_id to the correct existing node id
- Run graph validation and inspect the reported node_id to locate the broken reference
Example fix
# before
graph.delete_node("denoise") # edges still reference "denoise"
# after
for edge in list(graph.edges):
if "denoise" in (edge.source.node_id, edge.destination.node_id):
graph.delete_edge(edge)
graph.delete_node("denoise") Defensive patterns
Strategy: validation
Validate before calling
def check_edges_have_nodes(graph):
for edge in graph.edges:
if edge.source.node_id not in graph.nodes:
raise ValueError(f"edge source {edge.source.node_id} missing")
return True
check_edges_have_nodes(graph) # before adding/submitting Type guard
def edge_source_exists(graph, edge) -> bool:
return edge.source.node_id in graph.nodes Try / catch
from invokeai.app.services.shared.graph import NodeNotFoundError
try:
graph.add_edge(edge)
validate_graph(graph)
except NodeNotFoundError as e:
logger.error("dangling edge endpoint: %s", e)
graph.delete_edge(edge) Prevention
- Delete all edges attached to a node before deleting the node
- Add both endpoint nodes before adding any edges
- After renaming a node id, update every edge referencing the old id
When it happens
Trigger: Adding an edge (add_edge / EdgeConnection) whose source.node_id references a node never added to the graph, or that was removed (delete_node) while its edges remained, or whose id was renamed after the edge was created.
Common situations: Deleting a node from a workflow without deleting its connected edges; hand-editing workflow JSON and changing a node id referenced by an edge; copying edges between graphs; API clients sending edge payloads with typos in node_id.
Related errors
- Edge destination node {edge.destination.node_id} does not ex
- Edge source field {edge.source.field} does not exist in node
- Edge destination field {edge.destination.field} does not exi
- Node ids must match, got {node_dict_id} and {node.id}
- Destination node {edge.destination.node_id} has already been
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/b2a76144ed51550b.
Report an issue: GitHub.