{"record":{"id":"f0b1623337a3a0de","repo":"gastownhall/beads","slug":"applygraph-node-q-w","errorCode":null,"errorMessage":"applyGraph: node %q: %w","messagePattern":"applyGraph: node %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue.go","lineNumber":1138,"sourceCode":"\t\t// callers cannot route wisp-flagged issues into the durable table.\n\t\tif nodeWisp := node.Issue.Ephemeral || node.Issue.NoHistory; nodeWisp != useWisp {\n\t\t\treturn GraphApplyResult{}, fmt.Errorf(\"applyGraph: node %q storage class (ephemeral=%t, no_history=%t) does not match plan routing (wisp=%t)\", node.Key, node.Issue.Ephemeral, node.Issue.NoHistory, useWisp)\n\t\t}\n\n\t\tif node.AssignAfterCreate {\n\t\t\tpendingAssignees[i] = node.Assignee\n\t\t\tnode.Issue.Assignee = \"\"\n\t\t} else if node.Assignee != \"\" {\n\t\t\tnode.Issue.Assignee = node.Assignee\n\t\t}\n\n\t\tparams := CreateIssueParams{\n\t\t\tIssue:  node.Issue,\n\t\t\tLabels: node.Labels,\n\t\t}\n\t\tr, err := u.create(ctx, params, actor, useWisp)\n\t\tif err != nil {\n\t\t\treturn GraphApplyResult{}, fmt.Errorf(\"applyGraph: node %q: %w\", node.Key, err)\n\t\t}\n\t\tkeyToID[node.Key] = r.Issue.ID\n\t}\n\n\t// Pass 2 — resolve MetadataRefs now that every node has a minted ID.\n\t// Merges the resolved IDs into the issue's existing metadata JSON and\n\t// writes the result back via Update. Kept inside applyGraph so the CLI\n\t// cannot bypass this step; the proxied caller used to do it post-call.\n\tfor _, node := range plan.Nodes {\n\t\tif len(node.MetadataRefs) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tmetaJSON, err := types.MergeMetadataRefs(node.Issue.Metadata, node.MetadataRefs, keyToID)\n\t\tif err != nil {\n\t\t\treturn GraphApplyResult{}, fmt.Errorf(\"applyGraph: node %q: %w\", node.Key, err)\n\t\t}\n\t\tupdates := map[string]any{\"metadata\": metaJSON}\n\t\tif err := u.issueRepo.Update(ctx, keyToID[node.Key], updates, actor, IssueTableOpts{UseWispsTable: useWisp}); err != nil {","sourceCodeStart":1120,"sourceCodeEnd":1156,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue.go#L1120-L1156","documentation":"Wraps any error from the per-node create call during applyGraph pass 1 (inserting each node's issue), annotated with the node's key. Causes are the same as ordinary create failures: validation, prefix mismatch, dependency insert failures, storage errors. IDs minted for previously created nodes are tracked in keyToID, but the apply aborts on the first node failure.","triggerScenarios":"Calling ApplyGraph where u.create fails for a node — invalid issue fields, duplicate ID, bad dependency/label references, or a storage/driver error during insert.","commonSituations":"Graph files with malformed issue payloads; duplicates of already-existing issues; dependency edges referencing keys that fail to create; transient DB failures mid-apply.","solutions":["Read the node key and the wrapped inner error to pinpoint the failing issue payload","Fix the offending node's issue data (title, IDs, flags) and re-apply the plan","Make nodes idempotent/skippable if they already exist before re-running apply","Check storage connectivity/constraints if the wrapped error is driver-level"],"exampleFix":"// before: node issue missing required title\nplan.Nodes[2].Issue = &types.Issue{}\n// after: complete payload before apply\nplan.Nodes[2].Issue = &types.Issue{Title: \"child task\", Status: \"open\"}","handlingStrategy":"validation","validationCode":"for _, n := range plan.Nodes {\n    if n.Issue.Title == \"\" { return fmt.Errorf(\"node %q missing title\", n.Key) }\n    for _, dep := range n.Dependencies {\n        if !planHasKey(plan, dep.DependsOnKey) { return fmt.Errorf(\"node %q refs unknown key %q\", n.Key, dep.DependsOnKey) }\n    }\n}\n// also dedupe against existing issues before apply","typeGuard":null,"tryCatchPattern":"result, err := uc.ApplyGraph(ctx, plan, actor)\nif err != nil {\n    var key string\n    if _, e := fmt.Sscanf(err.Error(), \"applyGraph: node %q\", &key); e == nil {\n        log.Printf(\"graph apply failed at node %s\", key)\n        // inspect and fix that node, then re-apply idempotently\n    }\n}","preventionTips":["Validate every node payload (title, flags, deps) before apply","Ensure all dependency keys reference keys present in the plan","Check for pre-existing issues with the same IDs to keep apply idempotent","Regenerate graphs from source instead of hand-editing"],"tags":["graph-apply","create","storage","go"],"backgroundTag":"graph-node-create-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}