{"record":{"id":"96140206e78491d2","repo":"gastownhall/beads","slug":"node-q-updating-metadata-refs-w","errorCode":null,"errorMessage":"node %q: updating metadata refs: %w","messagePattern":"node %q: updating metadata refs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_apply.go","lineNumber":985,"sourceCode":"\n\t\tfor i, node := range plan.Nodes {\n\t\t\tkeyToID[node.Key] = issues[i].ID\n\t\t}\n\n\t\t// Resolve MetadataRefs now that all IDs are known.\n\t\tfor i, node := range plan.Nodes {\n\t\t\tif len(node.MetadataRefs) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmetaJSON, err := types.MergeMetadataRefs(issues[i].Metadata, node.MetadataRefs, keyToID)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"node %q: %w\", node.Key, err)\n\t\t\t}\n\t\t\tupdates := map[string]interface{}{\n\t\t\t\t\"metadata\": metaJSON,\n\t\t\t}\n\t\t\tif err := tx.UpdateIssue(ctx, issues[i].ID, updates, actor); err != nil {\n\t\t\t\treturn fmt.Errorf(\"node %q: updating metadata refs: %w\", node.Key, err)\n\t\t\t}\n\t\t}\n\n\t\tparentDepPairs := graphApplyParentDepPairs(plan.Nodes, keyToID)\n\t\tnewSchedulingEdges := make([][2]string, 0, len(plan.Nodes)+len(plan.Edges))\n\t\tif err := validateGraphApplyPlannedParentBlockingPaths(ctx, tx, plan, keyToID, parentDepPairs); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := validateGraphApplyPlannedBlockingCycles(ctx, tx, plan, keyToID); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i, edge := range plan.Edges {\n\t\t\tfromID := resolveEdgeRef(edge.FromKey, edge.FromID, keyToID)\n\t\t\ttoID := resolveEdgeRef(edge.ToKey, edge.ToID, keyToID)\n\t\t\tdepType := graphApplyDependencyType(edge.Type)\n\t\t\tif parentDepPairs[graphApplyDepPairKey(fromID, toID)] && depType != types.DepParentChild {\n\t\t\t\treturn fmt.Errorf(\"edge %d %s->%s duplicates a parent-child relationship with dependency type %q\", i, fromID, toID, depType)\n\t\t\t}","sourceCodeStart":967,"sourceCodeEnd":1003,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_apply.go#L967-L1003","documentation":"The follow-up `tx.UpdateIssue` that writes merged metadata back onto the freshly created issue failed. This is a storage-layer write failure specific to the metadata-ref step, wrapped with the node key; the transaction rolls back all created nodes.","triggerScenarios":"Driver/Dolt error during UpdateIssue: backend unavailable, row locked, I/O error, or the update payload rejected by the driver.","commonSituations":"Dolt server connection dropped mid-transaction; disk full; concurrent writer contending on the same issue row.","solutions":["Inspect the wrapped inner error for the storage cause.","Check Dolt/server health and connectivity, then re-run the apply.","Retry after resolving contention; the rollback makes re-application safe.","If persistent, verify no other process holds locks on the database."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := bd.GraphApply(ctx, plan)\nif err != nil && strings.Contains(err.Error(), \"updating metadata refs\") {\n  // transaction rolled back; check storage health then retry\n  return retryWithBackoff(func() error { _, err := bd.GraphApply(ctx, plan); return err }, 3)\n}","preventionTips":["Keep storage backend healthy; watch for connection drops mid-transaction.","Avoid concurrent writers on the same issues during apply.","Retry safely — rollback guarantees no partial state."],"tags":["cli","graph-apply","storage","transaction","update"],"backgroundTag":"storage-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}