{"record":{"id":"9faffd29e216220f","repo":"gastownhall/beads","slug":"w-apply-batch-item-d-must-not-carry-comments-or","errorCode":null,"errorMessage":"%w: apply batch item %d must not carry comments or dependencies on the issue; edges are their own items","messagePattern":"%w: apply batch item (.+?) must not carry comments or dependencies on the issue; edges are their own items","errorType":"validation","errorClass":"issueops.ErrValidation","httpStatus":null,"severity":"error","filePath":"internal/storage/batch_apply.go","lineNumber":150,"sourceCode":"\t\tcase issueops.ItemClose:\n\t\t\tmatches = item.Close != nil\n\t\tcase issueops.ItemDepAdd:\n\t\t\tmatches = item.DepAdd != nil\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"%w: apply batch item %d has unknown kind %q\", issueops.ErrValidation, i, item.Kind)\n\t\t}\n\t\tif !matches {\n\t\t\treturn nil, fmt.Errorf(\"%w: apply batch item %d is kind %q but carries another kind's payload\",\n\t\t\t\tissueops.ErrValidation, i, item.Kind)\n\t\t}\n\t\tif item.Create == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif item.Create.Issue == nil {\n\t\t\treturn nil, fmt.Errorf(\"%w: apply batch item %d requires an issue\", issueops.ErrValidation, i)\n\t\t}\n\t\tif len(item.Create.Issue.Comments) > 0 || len(item.Create.Issue.Dependencies) > 0 {\n\t\t\treturn nil, fmt.Errorf(\"%w: apply batch item %d must not carry comments or dependencies on the issue; edges are their own items\",\n\t\t\t\tissueops.ErrValidation, i)\n\t\t}\n\t\tif item.Create.Key == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif prior, dup := keyIndex[item.Create.Key]; dup {\n\t\t\treturn nil, fmt.Errorf(\"%w: apply batch item %d reuses key %q, already declared by item %d\",\n\t\t\t\tissueops.ErrValidation, i, item.Create.Key, prior)\n\t\t}\n\t\tkeyIndex[item.Create.Key] = i\n\t}\n\treturn keyIndex, nil\n}\n\n// planApplyBatchItem validates one item's refs, guards and edge metadata, and\n// records what it touches for the items after it.\nfunc planApplyBatchItem(item *issueops.ApplyItem, index int, keyIndex map[string]int, touched map[string]bool) error {\n\tswitch item.Kind {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/batch_apply.go#L132-L168","documentation":"In the apply batch model, comments and dependencies attached to a created issue are rejected: edges (comments/dependencies) must be submitted as their own top-level items in the same batch. This error fires when a create item's Issue carries non-empty Comments or Dependencies slices.","triggerScenarios":"PlanApplyBatch with an item like {Kind: ItemCreate, Create: &CreateItem{Issue: &Issue{Comments: []Comment{...}}}} — i.e. porting an old CreateIssueWithEdges-style call into the batch API without splitting the edges out.","commonSituations":"Migrating from a single-shot create-with-children API to the batched apply API; flattening a JSON export of an issue with its comments straight into one create item.","solutions":["Move each comment into its own item in the batch (create item first, comment items after)","Move each dependency into its own ItemDepAdd item, using keys to reference the created issue","Strip Comments/Dependencies from the Issue before adding it to the batch"],"exampleFix":"// before\nCreate: &issueops.CreateItem{Key: \"a\", Issue: &types.Issue{Title: \"T\", Comments: []types.Comment{{Body: \"note\"}}}}\n// after\nitems := []issueops.ApplyItem{\n  {Kind: issueops.ItemCreate, Create: &issueops.CreateItem{Key: \"a\", Issue: &types.Issue{Title: \"T\"}}},\n  {Kind: issueops.ItemDepAdd, DepAdd: &issueops.DepAddItem{Source: issueops.Ref{Key: \"a\"}, Target: issueops.Ref{Key: \"b\"}, Type: \"blocks\"}},\n}","handlingStrategy":"validation","validationCode":"for i, it := range items {\n  if it.Create != nil && it.Create.Issue != nil &&\n     (len(it.Create.Issue.Comments) > 0 || len(it.Create.Issue.Dependencies) > 0) {\n    return fmt.Errorf(\"create item %d carries edges; split them out\", i)\n  }\n}","typeGuard":"func issueCarriesEdges(is *types.Issue) bool {\n  return is != nil && (len(is.Comments) > 0 || len(is.Dependencies) > 0)\n}","tryCatchPattern":"if err := store.PlanApplyBatch(plan); err != nil {\n  if errors.Is(err, issueops.ErrValidation) && strings.Contains(err.Error(), \"edges are their own items\") {\n    // split comments/dependencies into their own batch items and retry\n  }\n  return err\n}","preventionTips":["Treat Issue.Comments/Dependencies as always-empty in batch API payloads","Convert legacy create-with-children calls into create + edge items","Keep a shared flattening helper that expands edges into sibling items"],"tags":["validation","batch-apply","edge-items"],"backgroundTag":"batch-item-nested-edges-forbidden","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}