gastownhall/beads · error

previewDelete: list deps: %w

Error message

previewDelete: list deps: %w

What it means

This error wraps a failure from depRepo.ListByIssueIDs with Direction=DepDirectionOut in previewDelete, which collects outgoing dependency records that would be deleted along with the issues. Preview is read-only; failure aborts the preview only.

Source

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

		preview.Issues[iss.ID] = iss
	}
	fromWisps, err := u.issueRepo.GetByIDs(ctx, ids, IssueTableOpts{UseWispsTable: true})
	if err != nil && !dberrors.IsTableNotExist(err) {
		return preview, fmt.Errorf("previewDelete: load wisps: %w", err)
	}
	for _, iss := range fromWisps {
		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 {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Fix the driver-level error from the wrapped cause.
  2. Retry the preview — it does not mutate data.
  3. Batch the ids if the list is very large.
  4. Check the dependencies table exists and is migrated.
Defensive patterns

Strategy: validation

Validate before calling

// Validate ids and connectivity before the preview:
if len(ids) == 0 {
    return nil
}
if err := store.PingContext(ctx); err != nil {
    return fmt.Errorf("db unreachable: %w", err)
}

Type guard

var dbErr *dberrors.DBError
if errors.As(err, &dbErr) {
    // distinguish connectivity vs data/scan errors
}

Try / catch

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

Prevention

When it happens

Trigger: PreviewDelete/PreviewDeleteWisp when the outgoing dependency bulk query on the main dependencies table fails: DB unreachable, timeout, oversized id list, or scan error.

Common situations: Transient connection loss during a dry-run; corrupted dependency rows; extremely wide cascade previews issuing heavy queries.

Related errors


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