gastownhall/beads · error

previewDelete: list wisp deps: %w

Error message

previewDelete: list wisp deps: %w

What it means

This error wraps a failure from depRepo.ListByIssueIDs with UseWispsTable=true and Direction=DepDirectionOut in previewDelete. Missing wisps tables are tolerated via dberrors.IsTableNotExist; other failures abort the preview.

Source

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

		preview.Issues[iss.ID] = iss
	}

	for _, id := range ids {
		if _, ok := preview.Issues[id]; !ok {
			preview.NotFound = append(preview.NotFound, id)
		}
	}

	depRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionOut})
	if err != nil {
		return preview, fmt.Errorf("previewDelete: list deps: %w", err)
	}
	for id, deps := range depRes.Outgoing {
		preview.DepRecords[id] = deps
	}
	wispDepRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionOut, UseWispsTable: true})
	if err != nil && !dberrors.IsTableNotExist(err) {
		return preview, fmt.Errorf("previewDelete: list wisp deps: %w", err)
	}
	for id, deps := range wispDepRes.Outgoing {
		preview.DepRecords[id] = append(preview.DepRecords[id], deps...)
	}

	allIDs, err := u.issueRepo.FindAllDependents(ctx, ids)
	if err != nil {
		return preview, fmt.Errorf("previewDelete: cascade expansion: %w", err)
	}
	deletedSet := make(map[string]bool, len(allIDs))
	for _, id := range allIDs {
		deletedSet[id] = true
	}
	connected, _, err := u.collectConnectedIssues(ctx, allIDs, deletedSet)
	if err != nil {
		return preview, err
	}
	preview.ConnectedIssues = connected

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped cause and address connectivity/timeout first.
  2. Re-run the preview after transient failures.
  3. Align the wisps schema via migrations if it diverged.
  4. If wisps are unused, confirm the table-not-exist path is what's expected (it is skipped silently).
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure wisps schema consistency before previewing wisp deletes:
if err := migrate(ctx); err != nil {
    return fmt.Errorf("wisps schema check failed: %w", err)
}

Type guard

if dberrors.IsTableNotExist(errors.Unwrap(err)) {
    return nil // tolerated: wisps table absent
}

Try / catch

preview, err := uc.PreviewDeleteWisp(ctx, ids)
if err != nil && strings.Contains(err.Error(), "previewDelete: list wisp deps") {
    if !dberrors.IsTableNotExist(errors.Unwrap(err)) {
        return fmt.Errorf("wisp dependency lookup failed: %w", err)
    }
}

Prevention

When it happens

Trigger: PreviewDelete/PreviewDeleteWisp when the wisps dependency table exists but the outgoing-dependency query fails for another reason: connection error, timeout, schema/scan mismatch.

Common situations: Concurrent wisp writes locking the table; upgrade left wisps schema inconsistent; DB outage during delete preview.

Related errors


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