{"record":{"id":"979005b1d91b9514","repo":"invoke-ai/InvokeAI","slug":"edge-destination-node-edge-destination-node-id-d","errorCode":null,"errorMessage":"Edge destination node {edge.destination.node_id} does not exist in the graph","messagePattern":"Edge destination node (.+?) does not exist in the graph","errorType":"validation","errorClass":"NodeNotFoundError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/shared/graph.py","lineNumber":1814,"sourceCode":"        seen = set()\n        duplicate_node_ids = {nid for nid in node_ids if (nid in seen) or seen.add(nid)}\n        if duplicate_node_ids:\n            raise DuplicateNodeIdError(f\"Node ids must be unique, found duplicates {duplicate_node_ids}\")\n\n    def _validate_node_id_mapping(self) -> None:\n        for node_dict_id, node in self.nodes.items():\n            if node_dict_id != node.id:\n                raise NodeIdMismatchError(f\"Node ids must match, got {node_dict_id} and {node.id}\")\n\n    def _validate_edge_nodes_and_fields(self) -> None:\n        for edge in self.edges:\n            source_node = self.nodes.get(edge.source.node_id, None)\n            if source_node is None:\n                raise NodeNotFoundError(f\"Edge source node {edge.source.node_id} does not exist in the graph\")\n\n            destination_node = self.nodes.get(edge.destination.node_id, None)\n            if destination_node is None:\n                raise NodeNotFoundError(f\"Edge destination node {edge.destination.node_id} does not exist in the graph\")\n\n            if edge.source.field not in source_node.get_output_annotation().model_fields:\n                raise NodeFieldNotFoundError(\n                    f\"Edge source field {edge.source.field} does not exist in node {edge.source.node_id}\"\n                )\n\n            if edge.destination.field not in type(destination_node).model_fields:\n                if isinstance(destination_node, CallSavedWorkflowInvocation) and is_call_saved_workflow_dynamic_input(\n                    edge.destination.field\n                ):\n                    continue\n                raise NodeFieldNotFoundError(\n                    f\"Edge destination field {edge.destination.field} does not exist in node {edge.destination.node_id}\"\n                )\n\n    def _validate_graph_is_acyclic(self) -> None:\n        graph = self.nx_graph_flat()\n        if not nx.is_directed_acyclic_graph(graph):","sourceCodeStart":1796,"sourceCodeEnd":1832,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/shared/graph.py#L1796-L1832","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the missing destination node to the graph","Remove the dangling edge from graph.edges","Fix the edge's destination.node_id to point at an existing node id","Validate the graph and check the destination.node_id named in the error message"],"exampleFix":"// before (workflow JSON)\n{\"source\": {\"node_id\": \"prompt\"}, \"destination\": {\"node_id\": \"denoize\"}}\n\n// after\n{\"source\": {\"node_id\": \"prompt\"}, \"destination\": {\"node_id\": \"denoise\"}}","handlingStrategy":"validation","validationCode":"def check_edge_destinations(graph):\n    for edge in graph.edges:\n        if edge.destination.node_id not in graph.nodes:\n            raise ValueError(f\"edge destination {edge.destination.node_id} missing\")\n    return True\n\ncheck_edge_destinations(graph)  # before validation/execution","typeGuard":"def edge_destination_exists(graph, edge) -> bool:\n    return edge.destination.node_id in graph.nodes","tryCatchPattern":"from invokeai.app.services.shared.graph import NodeNotFoundError\ntry:\n    validate_graph(graph)\nexcept NodeNotFoundError as e:\n    logger.error(\"edge references missing node: %s\", e)","preventionTips":["Never add an edge whose destination node has not been created yet","When merging graphs, copy nodes first, then edges","Validate node ids in client-supplied edge payloads before accepting them"],"tags":["graph","validation","invokeai","edges"],"backgroundTag":"graph-edge-dangling-node-reference","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}