gastownhall/beads · error

delete: drop wisp labels: %w

Error message

delete: drop wisp labels: %w

What it means

Same label cascade step as 'drop labels' but for the wisp-plane: labelRepo.DeleteAllForIDs with UseWispsTable:true removes label rows stored against wisps. A wrapped error here means the wisp label rows could not be deleted and the entire delete aborts to avoid inconsistent state.

Source

Thrown at internal/storage/domain/issue_delete.go:187

	if _, err := u.depRepo.DeleteAllForIDs(ctx, wispIDs, DepInsertOpts{UseWispsTable: true}); err != nil {
		return result, fmt.Errorf("delete: drop wisp deps: %w", err)
	}
	// The SYNC-PLANE edges pointing at a deleted wisp, which are not the same
	// rows as the line above and are not reached by a foreign key: there is no
	// FK from dependencies to wisps, so `dependencies.depends_on_wisp_id` rows
	// survive their target unless they are deleted explicitly. Without this a
	// forced delete of a wisp left its durable dependent holding an edge into
	// a row that no longer exists — dangling, not orphaned, which is not what
	// issueops.DeleteRequest.Force promises. The store body has always done
	// this (issueops.deleteIssueRowInTx -> DeleteWispFromDependenciesInTx).
	if _, err := u.depRepo.DeleteAllForIDs(ctx, wispIDs, DepInsertOpts{}); err != nil {
		return result, fmt.Errorf("delete: drop sync-plane edges into deleted wisps: %w", err)
	}
	if _, err := u.labelRepo.DeleteAllForIDs(ctx, regularIDs, LabelOpts{}); err != nil {
		return result, fmt.Errorf("delete: drop labels: %w", err)
	}
	if _, err := u.labelRepo.DeleteAllForIDs(ctx, wispIDs, LabelOpts{UseWispsTable: true}); err != nil {
		return result, fmt.Errorf("delete: drop wisp labels: %w", err)
	}
	if _, err := u.eventsRepo.DeleteAllForIDs(ctx, regularIDs, RecordEventOpts{}); err != nil {
		return result, fmt.Errorf("delete: drop events: %w", err)
	}
	if _, err := u.eventsRepo.DeleteAllForIDs(ctx, wispIDs, RecordEventOpts{UseWispsTable: true}); err != nil {
		return result, fmt.Errorf("delete: drop wisp events: %w", err)
	}

	issuesDeleted, err := u.issueRepo.DeleteByIDs(ctx, regularIDs, IssueTableOpts{})
	if err != nil {
		return result, fmt.Errorf("delete: drop issue rows: %w", err)
	}
	wispsDeleted, err := u.issueRepo.DeleteByIDs(ctx, wispIDs, IssueTableOpts{UseWispsTable: true})
	if err != nil {
		return result, fmt.Errorf("delete: drop wisp rows: %w", err)
	}
	result.DeletedCount = issuesDeleted + wispsDeleted

View on GitHub (pinned to 71377f2769)

Solutions

  1. Verify the wisps labels table exists; migrate the embedded schema if needed.
  2. Retry the delete — no partial rows persist on failure.
  3. Check the wrapped cause for lock/permission specifics.
  4. Chunk large wisp deletions to stay under lock timeouts.
Defensive patterns

Strategy: validation

Validate before calling

if err := ctx.Err(); err != nil { return err }
exists, err := tableExists(ctx, "wisps_labels"); if err != nil || !exists { return fmt.Errorf("wisp labels table missing — migrate schema") }

Type guard

var dbe *storage.DBError
if errors.As(err, &dbe) { /* inspect driver cause */ }

Try / catch

if err := store.DeleteWisps(ctx, ids, opts); err != nil {
    if strings.Contains(err.Error(), "delete: drop wisp labels:") { /* retry after schema/health check */ }
}

Prevention

When it happens

Trigger: Deleting wisps (DeleteWisp/DeleteWisps or mixed sets) when the wisps labels table is missing/locked, the driver errors, or the context/connection fails during the cascade.

Common situations: Older embedded DB without the wisps labels table; concurrent writer lock timeouts; transient connection drop during large wisp deletions.

Related errors


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