{"record":{"id":"203361ae99257547","repo":"invoke-ai/InvokeAI","slug":"destination-node-edge-destination-node-id-has-al","errorCode":null,"errorMessage":"Destination node {edge.destination.node_id} has already been prepared or executed and cannot be linked to","messagePattern":"Destination node (.+?) has already been prepared or executed and cannot be linked to","errorType":"exception","errorClass":"NodeAlreadyExecutedError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/shared/graph.py","lineNumber":2867,"sourceCode":"        self.graph.add_node(node)\n\n    def update_node(self, node_id: str, new_node: BaseInvocation) -> None:\n        if not self._is_node_updatable(node_id):\n            raise NodeAlreadyExecutedError(\n                f\"Node {node_id} has already been prepared or executed and cannot be updated\"\n            )\n        self.graph.update_node(node_id, new_node)\n\n    def delete_node(self, node_id: str) -> None:\n        if not self._is_node_updatable(node_id):\n            raise NodeAlreadyExecutedError(\n                f\"Node {node_id} has already been prepared or executed and cannot be deleted\"\n            )\n        self.graph.delete_node(node_id)\n\n    def add_edge(self, edge: Edge) -> None:\n        if not self._is_node_updatable(edge.destination.node_id):\n            raise NodeAlreadyExecutedError(\n                f\"Destination node {edge.destination.node_id} has already been prepared or executed and cannot be linked to\"\n            )\n        self.graph.add_edge(edge)\n\n    def delete_edge(self, edge: Edge) -> None:\n        if not self._is_node_updatable(edge.destination.node_id):\n            raise NodeAlreadyExecutedError(\n                f\"Destination node {edge.destination.node_id} has already been prepared or executed and cannot have a source edge deleted\"\n            )\n        self.graph.delete_edge(edge)\n","sourceCodeStart":2849,"sourceCodeEnd":2878,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/shared/graph.py#L2849-L2878","documentation":"GraphExecution.add_edge throws NodeAlreadyExecutedError when the edge's destination node has already been prepared or executed. Adding an edge to a finished node would retroactively change execution inputs, so it is forbidden. Mutate the graph before it is queued or enqueue a modified copy.","triggerScenarios":"Calling GraphExecution.add_edge(edge) where edge.destination.node_id is in the prepared/executed node list (_is_node_updatable returns False).","commonSituations":"Wiring late outputs into already-run nodes during a live session, editing graphs over the websocket while execution is in progress, or loop-style graphs that try to feed results back into executed nodes.","solutions":["Add all edges before enqueueing the graph","Create a new graph/queue item with the desired edge instead of editing the executed session","Catch NodeAlreadyExecutedError and handle (skip edge, notify user)","Guard with _is_node_updatable(edge.destination.node_id) before add_edge"],"exampleFix":"// before\nexecution.add_edge(edge)  # raises if destination already executed\n// after\nif execution._is_node_updatable(edge.destination.node_id):\n    execution.add_edge(edge)\nelse:\n    g = execution._graph.model_copy(deep=True)\n    g.add_edge(edge)\n    # enqueue g as a new queue item","handlingStrategy":"validation","validationCode":"if not execution._is_node_updatable(edge.destination.node_id):\n    raise SkipMutation(\"destination already executed\")\nexecution.add_edge(edge)","typeGuard":"def edge_target_mutable(execution, edge: Edge) -> bool:\n    return execution._is_node_updatable(edge.destination.node_id)","tryCatchPattern":"try:\n    execution.add_edge(edge)\nexcept NodeAlreadyExecutedError:\n    enqueue_new_graph_with_edge(graph, edge)","preventionTips":["Add all edges before queueing","Never feed executed nodes' outputs back into them via late edges","Clone the graph for post-run modifications"],"tags":["graph","invokeai","state-error","edges"],"backgroundTag":"immutable-state-modification","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}