{"record":{"id":"0cee8084a15ab890","repo":"gastownhall/beads","slug":"merge-slot-create-w","errorCode":null,"errorMessage":"merge-slot create: %w","messagePattern":"merge-slot create: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/merge_slot.go","lineNumber":54,"sourceCode":"// MergeSlotCreateImpl is the shared implementation of Storage.MergeSlotCreate.\nfunc MergeSlotCreateImpl(ctx context.Context, s Storage, actor string) (*types.Issue, error) {\n\tslotID := MergeSlotID(ctx, s)\n\n\t// Idempotent: return existing slot without error.\n\tif existing, err := s.GetIssue(ctx, slotID); err == nil && existing != nil {\n\t\treturn existing, nil\n\t}\n\n\tissue := &types.Issue{\n\t\tID:          slotID,\n\t\tTitle:       \"Merge Slot\",\n\t\tDescription: \"Exclusive access slot for serialized conflict resolution in the merge queue.\",\n\t\tIssueType:   types.TypeTask,\n\t\tStatus:      types.StatusOpen,\n\t\tPriority:    0,\n\t}\n\tif err := s.CreateIssue(ctx, issue, actor); err != nil {\n\t\treturn nil, fmt.Errorf(\"merge-slot create: %w\", err)\n\t}\n\tif err := s.AddLabel(ctx, slotID, mergeSlotLabel, actor); err != nil {\n\t\t// Non-fatal: label is cosmetic.\n\t\t_ = err\n\t}\n\treturn s.GetIssue(ctx, slotID)\n}\n\n// MergeSlotCheckImpl is the shared implementation of Storage.MergeSlotCheck.\nfunc MergeSlotCheckImpl(ctx context.Context, s Storage) (*MergeSlotStatus, error) {\n\tslotID := MergeSlotID(ctx, s)\n\tslot, err := s.GetIssue(ctx, slotID)\n\tif err != nil || slot == nil {\n\t\treturn nil, fmt.Errorf(\"merge slot not found: %s (run 'bd merge-slot create' first): %w\",\n\t\t\tslotID, ErrNotFound)\n\t}\n\tmeta := parseSlotMeta(slot)\n\treturn &MergeSlotStatus{","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/merge_slot.go#L36-L72","documentation":"MergeSlotCreateImpl creates the canonical merge-slot bead (id <prefix>-merge-slot) via s.CreateIssue, after an idempotent existence check. This error wraps any CreateIssue failure — e.g. a validation rejection, an ID conflict, or a database error — so the merge slot could not be created.","triggerScenarios":"Calling MergeSlotCreate (bd merge-slot create) when CreateIssue fails: the slot ID already exists but a concurrent create raced past the GetIssue check, the issue fails validation, the issue_prefix config changed producing a different slot ID, or the underlying store errors (connection, read-only DB, constraint).","commonSituations":"Two agents racing to create the slot simultaneously; issue_prefix reconfigured between the existence check and create; Dolt write failure or replication conflict; store in read-only/maintenance mode.","solutions":["Re-run the command — MergeSlotCreateImpl is idempotent; a transient race usually resolves on retry","Check the wrapped CreateIssue error for duplicate-ID vs validation cause and address specifically","Verify the issue_prefix config is stable and correct (MergeSlotID derives the slot ID from it)","Inspect store health (connectivity, read-only flags, Dolt logs) if the underlying write failed"],"exampleFix":"// before\nslot, err := store.MergeSlotCreate(ctx, actor)\nif err != nil { return err } // hard-fails on transient race\n// after\nslot, err := store.MergeSlotCreate(ctx, actor)\nif err != nil {\n\t// idempotent op — safe to retry once\n\tslot, err = store.MergeSlotCreate(ctx, actor)\n\tif err != nil { return fmt.Errorf(\"merge-slot create failed: %w\", err) }\n}","handlingStrategy":"retry","validationCode":"// idempotent create: safe to call regardless\nif _, err := store.MergeSlotCheck(ctx); err == nil {\n\t// slot already exists — skip create\n}","typeGuard":null,"tryCatchPattern":"slot, err := store.MergeSlotCreate(ctx, actor)\nif err != nil {\n\t// creation is idempotent — one retry absorbs create races\n\tif slot, err = store.MergeSlotCreate(ctx, actor); err != nil {\n\t\treturn fmt.Errorf(\"merge-slot create: %w\", err)\n\t}\n}","preventionTips":["Call MergeSlotCreate (idempotent) at agent startup instead of on demand","Keep issue_prefix config stable; change it in one coordinated rollout","Don't treat the slot bead as user data in cleanup scripts (identify by gt:slot label)","Retry once on failure — races between concurrent creators resolve on the second pass"],"tags":["merge-queue","issue-creation","concurrency"],"backgroundTag":"merge-slot-create-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}