gastownhall/beads · error

get dependency counts: probe: %w

Error message

get dependency counts: probe: %w

What it means

This error wraps a failure of wispsTableEmptyOrMissingInTx, the probe that decides whether GetDependencyCountsInTx needs to scan wisp_dependencies at all. If the probe query itself fails (as opposed to reporting the table is empty/missing), counts cannot proceed and this error is returned.

Source

Thrown at internal/storage/issueops/dependency_queries.go:442

	if err := tx.QueryRowContext(ctx, query, args...).Scan(&n); err != nil {
		return 0, fmt.Errorf("count dependent records from %s: %w", depTable, err)
	}
	return n, nil
}

func GetDependencyCountsInTx(ctx context.Context, tx DBTX, issueIDs []string) (map[string]*types.DependencyCounts, error) {
	if len(issueIDs) == 0 {
		return make(map[string]*types.DependencyCounts), nil
	}

	result := make(map[string]*types.DependencyCounts)
	for _, id := range issueIDs {
		result[id] = &types.DependencyCounts{}
	}

	depTables := []string{"dependencies", "wisp_dependencies"}
	if empty, probeErr := wispsTableEmptyOrMissingInTx(ctx, tx); probeErr != nil {
		return nil, fmt.Errorf("get dependency counts: probe: %w", probeErr)
	} else if empty {
		depTables = []string{"dependencies"}
	}

	for start := 0; start < len(issueIDs); start += queryBatchSize {
		end := start + queryBatchSize
		if end > len(issueIDs) {
			end = len(issueIDs)
		}
		batch := issueIDs[start:end]

		placeholders := make([]string, len(batch))
		args := make([]any, len(batch))
		for i, id := range batch {
			placeholders[i] = "?"
			args[i] = id
		}
		inClause := strings.Join(placeholders, ",")

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped probe error to see the underlying cause.
  2. If it's a permission or detection issue, ensure the probe's isTableNotExistError/empty classification matches your driver's behavior.
  3. Run migrations/repair so the wisps and wisp_dependencies tables are in an expected state.
  4. Retry on transient connection or deadline errors; extend the context deadline for large hydrations.
  5. Verify DB grants cover all wisps-related tables.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate the wisps probe environment: table state is classifiable
var one int
if err := tx.QueryRowContext(ctx, "SELECT 1 FROM wisps LIMIT 1").Scan(&one); err != nil && !isTableNotExistError(err) {
    return fmt.Errorf("wisps probe will fail during hydration: %w", err)
}

Type guard

func wispsProbeWillSucceed(ctx context.Context, tx DBTX) bool {
    _, err := wispsTableEmptyOrMissingInTx(ctx, tx)
    return err == nil
}

Try / catch

counts, err := GetDependencyCountsInTx(ctx, tx, issueIDs)
if err != nil && strings.Contains(err.Error(), "probe: ") {
    // classify underlying cause: permissions vs connection vs schema; fix environment, not retry blindly
}

Prevention

When it happens

Trigger: Calling GetDependencyCountsInTx (e.g. via HydrateReadyRowInTx) when the wisps-table probe query fails: the probe's underlying table is inaccessible in an unexpected way, the context is canceled, the connection drops, or the driver returns an error the probe doesn't classify as 'missing/empty'.

Common situations: Permission errors on the wisps table that the missing-table detection misreads; connection instability during hydration; context deadline exceeded while hydrating many rows; corrupt storage preventing the probe's metadata read.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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