{"record":{"id":"2b8c7a2b4a31e304","repo":"gastownhall/beads","slug":"w-create-batch-item-d-requires-an-issue","errorCode":null,"errorMessage":"%w: create batch item %d requires an issue","messagePattern":"%w: create batch item (.+?) requires an issue","errorType":"validation","errorClass":"storage.ErrValidation","httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/create_batch.go","lineNumber":45,"sourceCode":"\n// ValidateCreateBatchRequest applies the request rules every BatchCreator\n// implementation shares. It runs BEFORE any transaction opens: everything it\n// checks is knowable from the request alone, so a batch refused here has\n// provably written nothing.\n//\n// Per-item CONTENT rules are not here. They need the workspace's configured\n// prefix, statuses and types, so they run inside the transaction through the\n// same PreparePublicCreateRequest a single create runs.\nfunc ValidateCreateBatchRequest(request publicops.CreateBatchRequest) error {\n\tif request.Actor == \"\" {\n\t\treturn fmt.Errorf(\"%w: create batch requires an actor\", storage.ErrValidation)\n\t}\n\tif len(request.Items) == 0 {\n\t\treturn fmt.Errorf(\"%w: create batch requires at least one item\", storage.ErrValidation)\n\t}\n\tfor i, item := range request.Items {\n\t\tif item.Issue == nil {\n\t\t\treturn fmt.Errorf(\"%w: create batch item %d requires an issue\", storage.ErrValidation, i)\n\t\t}\n\t}\n\treturn nil\n}\n\n// CreateBatchItemRequest projects one item onto the single-create request the\n// shared preparation and validation speak. Both front doors and both bodies read\n// an item through it, so no item restates CreateRequest's field rules.\nfunc CreateBatchItemRequest(request publicops.CreateBatchRequest, item publicops.BatchCreateItem) publicops.CreateRequest {\n\treturn publicops.CreateRequest{\n\t\tActor:         request.Actor,\n\t\tIssue:         item.Issue,\n\t\tDependencies:  item.Dependencies,\n\t\tForceIDPrefix: request.ForceIDPrefix,\n\t}\n}\n\n// CreateBatchItemError names the item a batch refusal came from. The role","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/create_batch.go#L27-L63","documentation":"Validation error from ValidateCreateBatchRequest: every item in a CreateBatchRequest must carry a non-nil Issue pointer. It wraps storage.ErrValidation and runs before any transaction opens, so a batch refused here has provably written nothing. The library throws it to catch callers building batch items without assigning the issue payload.","triggerScenarios":"Calling any BatchCreator's ExecuteCreateBatch with request.Items[i].Issue == nil — e.g. constructing BatchCreateItem{Issue: nil} or appending an item before filling its Issue field.","commonSituations":"Programmatically building batches from parsed input where an entry fails to map to an issue; partial struct initialization in loops; nil entries from a slice of optional issues not filtered before batching.","solutions":["Find item index N named in the message and set its Issue field to a non-nil *types.Issue before calling ExecuteCreateBatch","Filter nil issues out of the items slice before building the CreateBatchRequest","Run ValidateCreateBatchRequest (or your own nil-check loop) client-side before invoking the batch"],"exampleFix":"// before\nitems := []publicops.BatchCreateItem{{Issue: &a}, {}}\n// after\nitems := []publicops.BatchCreateItem{{Issue: &a}, {Issue: &b}}","handlingStrategy":"validation","validationCode":"for i, item := range req.Items {\n    if item.Issue == nil {\n        return fmt.Errorf(\"item %d has nil Issue\", i)\n    }\n}\n// then call ExecuteCreateBatch","typeGuard":"func hasIssue(item publicops.BatchCreateItem) bool { return item.Issue != nil }","tryCatchPattern":null,"preventionTips":["Build items through a constructor that requires a non-nil Issue","Filter nil issues before batching","Call ValidateCreateBatchRequest yourself first for fast-fail"],"tags":["validation","batch-create","nil-value"],"backgroundTag":"batch-item-missing-issue","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}