{"record":{"id":"5e442b882486409e","repo":"gastownhall/beads","slug":"node-q-parent-key-q-not-found-in-plan","errorCode":null,"errorMessage":"node %q: parent key %q not found in plan","messagePattern":"node %q: parent key %q not found in plan","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_apply.go","lineNumber":576,"sourceCode":"\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !found {\n\t\t\t\t\treturn fmt.Errorf(\"node %q: metadata ref %q references unknown key %q\", node.Key, metaKey, refKey)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tparentKey := node.effectiveParentKey()\n\t\tif parentKey != \"\" && !seenKeys[parentKey] {\n\t\t\tfound := false\n\t\t\tfor _, other := range plan.Nodes {\n\t\t\t\tif other.Key == parentKey {\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\treturn fmt.Errorf(\"node %q: parent key %q not found in plan\", node.Key, parentKey)\n\t\t\t}\n\t\t}\n\t\tfor j, dep := range node.Deps {\n\t\t\tif dep.Target == \"\" {\n\t\t\t\treturn fmt.Errorf(\"node %q: dep %d has empty target\", node.Key, j)\n\t\t\t}\n\t\t\tif dep.Type != \"\" {\n\t\t\t\tdt := types.DependencyType(dep.Type)\n\t\t\t\tif !dt.IsValid() {\n\t\t\t\t\treturn fmt.Errorf(\"node %q: dep %d: invalid dependency type %q\", node.Key, j, dep.Type)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i, edge := range plan.Edges {\n\t\tif edge.FromKey != \"\" && !seenKeys[edge.FromKey] {\n\t\t\treturn fmt.Errorf(\"edge %d: from key %q not found in plan\", i, edge.FromKey)","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_apply.go#L558-L594","documentation":"A node's effective parent key (from parent_key or hierarchy hints) must correspond to a node in the plan. If the parent key is set but not found among plan nodes, validation fails because hierarchical structure cannot be resolved.","triggerScenarios":"`bd graph apply` with a node whose parent_key names a key absent from plan.nodes.","commonSituations":"Typos in parent_key; deleting or renaming a parent node without updating children; expecting the parent to come from the existing tracker rather than the plan.","solutions":["Fix the parent_key spelling to match a node key in the plan","Add the parent node to plan.nodes","Remove or blank the parent_key if the node should be a root"],"exampleFix":"// before\n{\"key\": \"child\", \"parent_key\": \"parnet\"}\n// after\n{\"key\": \"child\", \"parent_key\": \"parent\"}","handlingStrategy":"validation","validationCode":"keys := map[string]bool{}\nfor _, n := range plan.Nodes { keys[n.Key] = true }\nfor _, n := range plan.Nodes {\n\tif p := n.EffectiveParentKey(); p != \"\" && !keys[p] { return fmt.Errorf(\"node %s: parent %s missing\", n.Key, p) }\n}","typeGuard":null,"tryCatchPattern":"if err := bd.GraphApply(ctx, plan, opts); err != nil {\n\tif strings.Contains(err.Error(), \"parent key\") && strings.Contains(err.Error(), \"not found in plan\") {\n\t\t// fix or drop parent_key and retry\n\t}\n}","preventionTips":["Keep parent and child nodes in the same plan","Rename keys with search-and-replace across the whole plan","Treat roots as parent_key:\"\" explicitly"],"tags":["validation","graph-apply","dangling-reference"],"backgroundTag":"unknown-reference-key","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}