{"record":{"id":"7655ad7761bc276b","repo":"gastownhall/beads","slug":"batch-create-w","errorCode":null,"errorMessage":"batch create: %w","messagePattern":"batch create: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_apply.go","lineNumber":965,"sourceCode":"\n\t\tfor i, node := range plan.Nodes {\n\t\t\tissue, err := graphApplyNodeIssue(node, opts, actor, owner)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif node.Assignee != \"\" {\n\t\t\t\tif node.AssignAfterCreate {\n\t\t\t\t\tpendingAssignees[i] = node.Assignee\n\t\t\t\t} else {\n\t\t\t\t\tissue.Assignee = node.Assignee\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tissues = append(issues, issue)\n\t\t}\n\n\t\tif err := tx.CreateIssues(ctx, issues, actor); err != nil {\n\t\t\treturn fmt.Errorf(\"batch create: %w\", err)\n\t\t}\n\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}","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_apply.go#L947-L983","documentation":"Inside the apply transaction, `tx.CreateIssues` bulk-inserts all plan nodes' issues. Any storage/DB failure is wrapped as `batch create: ...`, and because it happens in a transaction the entire graph apply is rolled back — no partial nodes are left behind.","triggerScenarios":"Any underlying driver/Dolt error during batch insert: constraint violations, storage backend unavailable, invalid field values that pass client validation but fail at the driver, or I/O errors.","commonSituations":"Dolt server down or unreachable mid-apply; duplicate issue keys colliding with existing data; corrupted local Dolt database; disk full.","solutions":["Inspect the wrapped inner error to identify the driver-level cause.","Verify the storage backend (Dolt) is running and reachable.","Check for duplicate/conflicting issue keys already present in the database.","Re-run the apply after fixing storage conditions; the transactional rollback means retry is safe."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := bd Doctor/health check; storage unreachable, abort before apply:\nif !storageReachable(doltAddr) { return errors.New(\"storage backend unavailable; aborting graph apply\") }","typeGuard":null,"tryCatchPattern":"err := bd.GraphApply(ctx, plan)\nif err != nil && strings.HasPrefix(err.Error(), \"batch create:\") {\n  // transaction rolled back; safe to retry after checking backend health\n  return retryWithBackoff(func() error { _, err := bd.GraphApply(ctx, plan); return err }, 3)\n}","preventionTips":["Verify Dolt/server health before large applies.","Ensure the plan has no keys colliding with existing issues.","Monitor disk space on the storage host.","Rely on transactional rollback — retries are safe."],"tags":["cli","graph-apply","storage","transaction","batch-insert"],"backgroundTag":"batch-insert-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}