gastownhall/beads · error

failed to create digest issue: %w

Error message

failed to create digest issue: %w

What it means

Inside the squash transaction, squashMoleculeInto creates the digest issue summarizing the molecule. If w.CreateIssue fails, the error is wrapped as 'failed to create digest issue: %w'. Because this happens inside a transact() block, the whole squash rolls back — no children are deleted.

Source

Thrown at cmd/bd/mol_squash.go:298

		Description: digestContent,
		Status:      types.StatusClosed,
		CloseReason: fmt.Sprintf("Squashed from %d wisps", len(children)),
		Priority:    root.Priority,
		IssueType:   types.TypeTask,
		Ephemeral:   false, // Digest is permanent, not a wisp
		ClosedAt:    &now,
	}

	result := &SquashResult{
		MoleculeID:    root.ID,
		SquashedIDs:   childIDs,
		SquashedCount: len(children),
		KeptChildren:  keepChildren,
	}

	// Create digest issue
	if err := w.CreateIssue(ctx, digestIssue, actorName); err != nil {
		return nil, fmt.Errorf("failed to create digest issue: %w", err)
	}
	result.DigestID = digestIssue.ID

	// Link digest to root as parent-child
	dep := &types.Dependency{
		IssueID:     digestIssue.ID,
		DependsOnID: root.ID,
		Type:        types.DepParentChild,
	}
	if err := w.AddDependency(ctx, dep, actorName); err != nil {
		return nil, fmt.Errorf("failed to link digest to root: %w", err)
	}

	// Delete ephemeral children within the same transaction
	if !keepChildren {
		for _, id := range childIDs {
			if err := w.DeleteIssue(ctx, id, actorName); err != nil {
				return nil, fmt.Errorf("failed to delete child %s: %w", id, err)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause for the specific CreateIssue failure (constraint, lock, IO)
  2. Ensure no other bd process is writing; close concurrent sessions and retry
  3. Verify database is writable and has free disk space
  4. Run bd doctor to check schema/version compatibility, then retry the squash
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure DB is writable before starting the squash
if err := s.CreateIssue(ctx, probeIssue, actor); err != nil {
    return fmt.Errorf("storage not writable: %w", err)
}

Try / catch

res, err := squashMolecule(ctx, s, root, children, keep, summary, actor)
if err != nil {
    var target *fmt.WrapError // or inspect message
    if strings.Contains(err.Error(), "failed to create digest issue") {
        log.Printf("digest creation failed; transaction rolled back: %v", errors.Unwrap(err))
    }
    return err
}

Prevention

When it happens

Trigger: bd mol squash when inserting the digest issue fails: constraint violations (e.g., duplicate ID, invalid priority/status), storage write error, or database locked/unavailable mid-transaction.

Common situations: Read-only database file or full disk; concurrent bd process holding the write lock; schema mismatch after version upgrade; digest title/content violating validation rules.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/3f15d22f7e45fe13. Report an issue: GitHub.