invoke-ai/InvokeAI · error · NodeNotFoundError

Edge destination node {edge.destination.node_id} does not ex

Error message

Edge destination node {edge.destination.node_id} does not exist in the graph

What it means

NodeNotFoundError is raised when validating a graph and an edge's `destination.node_id` does not exist in the graph's nodes dict. Just like the source variant, both endpoints of an edge must refer to nodes actually present in the graph.

Source

Thrown at invokeai/app/services/shared/graph.py:1814

        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}"
                )

    def _validate_graph_is_acyclic(self) -> None:
        graph = self.nx_graph_flat()
        if not nx.is_directed_acyclic_graph(graph):

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Add the missing destination node to the graph
  2. Remove the dangling edge from graph.edges
  3. Fix the edge's destination.node_id to point at an existing node id
  4. Validate the graph and check the destination.node_id named in the error message

Example fix

// before (workflow JSON)
{"source": {"node_id": "prompt"}, "destination": {"node_id": "denoize"}}

// after
{"source": {"node_id": "prompt"}, "destination": {"node_id": "denoise"}}
Defensive patterns

Strategy: validation

Validate before calling

def check_edge_destinations(graph):
    for edge in graph.edges:
        if edge.destination.node_id not in graph.nodes:
            raise ValueError(f"edge destination {edge.destination.node_id} missing")
    return True

check_edge_destinations(graph)  # before validation/execution

Type guard

def edge_destination_exists(graph, edge) -> bool:
    return edge.destination.node_id in graph.nodes

Try / catch

from invokeai.app.services.shared.graph import NodeNotFoundError
try:
    validate_graph(graph)
except NodeNotFoundError as e:
    logger.error("edge references missing node: %s", e)

Prevention

When it happens

Trigger: Adding an edge whose destination.node_id references a nonexistent node — e.g. the target node was never added, was deleted while its incoming edges remained, or its id was changed after the edge was created.

Common situations: Workflow JSON edits renaming the destination node id without updating edges; API clients building edge lists before creating the destination node; graph merging where one side's nodes were dropped.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/979005b1d91b9514. Report an issue: GitHub.