{"record":{"id":"720380590996af47","repo":"gastownhall/beads","slug":"node-q-adding-parent-child-dep-w","errorCode":null,"errorMessage":"node %q: adding parent-child dep: %w","messagePattern":"node %q: adding parent-child dep: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_apply.go","lineNumber":1025,"sourceCode":"\t\t}\n\n\t\t// Add node parent-child dependencies first. The explicit and inline\n\t\t// dependency sources below are also processed parent-first, so every\n\t\t// blocking edge sees the plan's full hierarchy in storage.\n\t\tfor i, node := range plan.Nodes {\n\t\t\tparentKey := node.effectiveParentKey()\n\t\t\tparentID := node.ParentID\n\t\t\tif parentKey != \"\" {\n\t\t\t\tparentID = keyToID[parentKey]\n\t\t\t}\n\t\t\tif parentID != \"\" {\n\t\t\t\tdep := &types.Dependency{\n\t\t\t\t\tIssueID:     issues[i].ID,\n\t\t\t\t\tDependsOnID: parentID,\n\t\t\t\t\tType:        types.DepParentChild,\n\t\t\t\t}\n\t\t\t\tif err := tx.AddDependency(ctx, dep, actor); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"node %q: adding parent-child dep: %w\", node.Key, err)\n\t\t\t\t}\n\t\t\t\tnewSchedulingEdges = append(newSchedulingEdges, [2]string{dep.IssueID, dep.DependsOnID})\n\t\t\t}\n\t\t}\n\n\t\tfor phase := 0; phase < 2; phase++ {\n\t\t\tparentPhase := phase == 0\n\t\t\t// Add explicit edges in stable order for this phase.\n\t\t\tfor i, edge := range plan.Edges {\n\t\t\t\tfromID := resolveEdgeRef(edge.FromKey, edge.FromID, keyToID)\n\t\t\t\ttoID := resolveEdgeRef(edge.ToKey, edge.ToID, keyToID)\n\t\t\t\tdepType := graphApplyDependencyType(edge.Type)\n\t\t\t\tif (depType == types.DepParentChild) != parentPhase {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif parentDepPairs[graphApplyDepPairKey(fromID, toID)] {\n\t\t\t\t\tif depType == types.DepParentChild {\n\t\t\t\t\t\tcontinue","sourceCodeStart":1007,"sourceCodeEnd":1043,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_apply.go#L1007-L1043","documentation":"This error wraps a storage-layer failure that occurred while inserting the parent-child dependency for a node during `bd graph apply`. Every node that declares a parent gets a DepParentChild dependency written inside the apply transaction; if tx.AddDependency rejects it (e.g. the referenced parent ID does not exist or the storage layer errors), the whole apply transaction is aborted and the underlying reason is wrapped with the node key for identification.","triggerScenarios":"Applying a graph plan where a node has a non-empty parentKey/ParentID and tx.AddDependency(ctx, dep, actor) returns an error — typically because the parent issue ID is not present in the database, a dependency constraint is violated, or the storage backend failed mid-transaction.","commonSituations":"Graph JSON files referencing parent keys that don't resolve to created issues, applying a plan against a database where the parent was deleted, or a corrupt/locked Dolt storage connection.","solutions":["Verify every node's parent key exists in the plan's nodes section and resolves via keyToID","Check the database still contains the parent issue (bd show <parent-id>) before applying","Re-generate the graph plan from a fresh export so parent references match current IDs","Inspect the wrapped underlying error for storage-specific causes (lock, connectivity)"],"exampleFix":"// before: plan references a parent key absent from the plan\n{\"key\":\"child\",\"parent\":\"task-9\"} // task-9 not in nodes\n// after: ensure the parent node is declared in the same plan\n{\"key\":\"task-9\",...},{\"key\":\"child\",\"parent\":\"task-9\"}","handlingStrategy":"validation","validationCode":"for _, n := range plan.Nodes {\n  if n.Parent != \"\" && !keysInPlanOrDB(n.Parent) {\n    return fmt.Errorf(\"node %q: parent %q not found\", n.Key, n.Parent)\n  }\n}","typeGuard":"func parentResolves(n Node, keyToID map[string]string) bool {\n  return n.Parent == \"\" || keyToID[n.Parent] != \"\"\n}","tryCatchPattern":"if err := bd.GraphApply(ctx, plan); err != nil {\n  var npe *NodeParentError\n  if errors.As(err, &npe) { /* fix plan parent refs */ }\n  return err\n}","preventionTips":["Always declare parent nodes in the same plan before children reference them","Regenerate plans from a fresh export rather than hand-editing IDs","Run bd show on parent IDs before applying"],"tags":["beads","graph-apply","dependency","storage"],"backgroundTag":"parent-issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}