{"record":{"id":"3a4ab8dd3da67c3c","repo":"GraphiteEditor/Graphite","slug":"node-not-found-in-lookup-table","errorCode":null,"errorMessage":"node not found in lookup table","messagePattern":"node not found in lookup table","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"node-graph/graph-craft/src/proto.rs","lineNumber":521,"sourceCode":"\n\t/// Sort the nodes vec so it is in a topological order. This ensures that no node takes an input from a node that is found later in the list.\n\tfn reorder_ids(&mut self) -> Result<(), String> {\n\t\tlet (order, _id_map) = self.topological_sort()?;\n\n\t\t// // Map of node ids to their current index in the nodes vector\n\t\t// let current_positions: FxHashMap<_, _> = self.nodes.iter().enumerate().map(|(pos, (id, _))| (*id, pos)).collect();\n\n\t\t// // Map of node ids to their new index based on topological order\n\t\tlet new_positions: FxHashMap<_, _> = order.iter().enumerate().map(|(pos, id)| (self.nodes[id.0 as usize].0, pos)).collect();\n\t\t// assert_eq!(id_map, current_positions);\n\n\t\t// Create a new nodes vector based on the topological order\n\n\t\tlet mut new_nodes = Vec::with_capacity(order.len());\n\t\tfor (index, &id) in order.iter().enumerate() {\n\t\t\tlet mut node = std::mem::take(&mut self.nodes[id.0 as usize].1);\n\t\t\t// Update node references to reflect the new order\n\t\t\tnode.map_ids(|id| NodeId(*new_positions.get(&id).expect(\"node not found in lookup table\") as u64));\n\t\t\tnew_nodes.push((NodeId(index as u64), node));\n\t\t}\n\n\t\t// Update node references to reflect the new order\n\t\t// new_nodes.iter_mut().for_each(|(_, node)| {\n\t\t// \tnode.map_ids(|id| *new_positions.get(&id).expect(\"node not found in lookup table\"), false);\n\t\t// });\n\n\t\t// Update the nodes vector and other references\n\t\tself.nodes = new_nodes;\n\t\tself.inputs = self.inputs.iter().filter_map(|id| new_positions.get(id).map(|x| NodeId(*x as u64))).collect();\n\t\tself.output = NodeId(*new_positions.get(&self.output).unwrap() as u64);\n\n\t\tassert_eq!(order.len(), self.nodes.len());\n\t\tOk(())\n\t}\n}\n#[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)]","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/GraphiteEditor/Graphite/blob/c507b356453361e31638b8bff8f6d46b6da2961e/node-graph/graph-craft/src/proto.rs#L503-L539","documentation":"During topological reordering of a ProtoNetwork, every node id is remapped through new_positions, which only contains nodes present in the topological order. Any reference to a node outside that order misses the lookup table and panics — the network references something the compiled order does not include.","triggerScenarios":"A node reference pointing at a node excluded from the DFS topological order (disconnected, or only referenced from filtered inputs); nested network inlining that leaves stale ids; graphs where the ordering pass drops nodes.","commonSituations":"Compiling macro-generated or hand-assembled networks; version drift between graph-craft's compiler expectations and the document structure feeding it.","solutions":["Reproduce with the failing document and compare referenced ids against the topological order to find the excluded node","Ensure every referenced node is reachable from the network inputs/output before compiling","Report the minimal failing graph upstream — the compiler should return an error, not panic, on out-of-order references"],"exampleFix":"// before\nnode.map_ids(|id| NodeId(*new_positions.get(&id).expect(\"node not found in lookup table\") as u64));\n\n// after\nnode.map_ids(|id| match new_positions.get(&id) {\n\tSome(pos) => NodeId(*pos as u64),\n\tNone => {\n\t\tlog::warn!(\"reference to node {id:?} outside topological order; leaving as-is\");\n\t\tid\n\t}\n});","handlingStrategy":"validation","validationCode":"// before compiling, every referenced id must appear in the topological order\nlet referenced: HashSet<NodeId> = /* collect from inputs/output */;\nassert!(referenced.iter().all(|id| order.contains(id)), \"graph references nodes outside the topological order\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build graphs only through APIs that keep inputs, output, and node ids consistent","Round-trip test macro-generated networks through compile before shipping","Treat any compiler panic on a valid-looking graph as a bug to minimize and report"],"tags":["node-graph","compiler","topological-sort","graphite"],"backgroundTag":"invalid-node-topology","analyzedSha":"c507b356453361e31638b8bff8f6d46b6da2961e","analyzedAt":"2026-08-16T21:57:18.596Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}