gastownhall/beads · error

count blocked issues: %w

Error message

count blocked issues: %w

What it means

GetStatisticsInTx counts blocked non-closed/non-pinned issues with a QueryRowContext().Scan(&blocked) and wraps any failure with this message. Like 3803, this is a single-row aggregate scan failing due to a broken connection, missing table/column, or cancelled context. The is_blocked column must exist and be maintained by the shared layer.

Source

Thrown at internal/storage/issueops/statistics.go:53

}

// GetStatisticsInTx computes the full summary statistics (counts + blocked + ready)
// in one transaction, using only the normal issues table — no version-control state —
// so it is portable across every SQL backend. Behaviorally identical to the Dolt and
// embedded-Dolt implementations: ScanIssueCountsInTx for the status counts, a direct
// blocked count (the is_blocked flag is maintained in-tx by the shared layer), then
// ReadyIssues = OpenIssues - BlockedIssues clamped at zero.
func GetStatisticsInTx(ctx context.Context, tx DBTX) (*types.Statistics, error) {
	stats := &types.Statistics{}
	if err := ScanIssueCountsInTx(ctx, tx, stats); err != nil {
		return nil, err
	}
	var blocked int
	if err := tx.QueryRowContext(ctx, `
		SELECT COUNT(*) FROM issues
		WHERE is_blocked = 1 AND status <> 'closed' AND status <> 'pinned'
	`).Scan(&blocked); err != nil {
		return nil, fmt.Errorf("count blocked issues: %w", err)
	}
	stats.BlockedIssues = &blocked
	ready := stats.OpenIssues - blocked
	if ready < 0 {
		ready = 0
	}
	stats.ReadyIssues = &ready
	return stats, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped error for 'unknown column is_blocked' and run schema migrations to the current version.
  2. Retry statistics with a fresh transaction if the connection dropped mid-call.
  3. Verify the Dolt server is healthy and the ctx timeout accommodates the blocked-count scan.
  4. If using an embedded backend, confirm the database file was opened read-write so migrations can apply.

Example fix

// before
stats, err := GetStatisticsInTx(ctx, tx) // unknown column is_blocked
// after
if err := store.Migrate(ctx); err != nil { return err } // add is_blocked column
stats, err := GetStatisticsInTx(ctx, tx)
Defensive patterns

Strategy: validation

Validate before calling

// confirm the is_blocked column exists before computing statistics
rows, err := tx.QueryContext(ctx, `SHOW COLUMNS FROM issues LIKE 'is_blocked'`)
if err != nil || !rows.Next() { return fmt.Errorf("schema out of date; run migrations") }

Try / catch

stats, err := issueops.GetStatisticsInTx(ctx, tx)
if err != nil && strings.Contains(err.Error(), "count blocked issues") {
    return fmt.Errorf("blocked-count failed (schema/connection): %w", err)
}

Prevention

When it happens

Trigger: The issues table lacks the is_blocked column (older schema); the tx/connection failed between the counts query and this one; context deadline exceeded; the underlying database rejected the SELECT syntax.

Common situations: Running a newer beads binary against a database created by an older version (pre-is_blocked schema); server connection dropped mid-GetStatisticsInTx; DB under heavy load timing out the stats call.

Related errors


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