gastownhall/beads · error

check issue existence in %s: %w

Error message

check issue existence in %s: %w

What it means

PresentIssueOrWispIDsInTx failed while executing the existence probe SELECT id FROM <table> WHERE id IN (...) against the issues or wisps table. The driver error is wrapped with the table name. A missing wisps table is tolerated (treated as no wisps), but any other query error aborts the read/count.

Source

Thrown at internal/storage/issueops/edges.go:158

		for start := 0; start < len(ids); start += queryBatchSize {
			end := start + queryBatchSize
			if end > len(ids) {
				end = len(ids)
			}
			batch := ids[start:end]
			placeholders := make([]string, len(batch))
			args := make([]any, len(batch))
			for i, id := range batch {
				placeholders[i] = "?"
				args[i] = id
			}
			rows, err := tx.QueryContext(ctx, fmt.Sprintf(
				"SELECT id FROM %s WHERE id IN (%s)", table, strings.Join(placeholders, ",")), args...)
			if err != nil {
				if isTableNotExistError(err) {
					break
				}
				return nil, fmt.Errorf("check issue existence in %s: %w", table, err)
			}
			for rows.Next() {
				var id string
				if scanErr := rows.Scan(&id); scanErr != nil {
					_ = rows.Close()
					return nil, fmt.Errorf("check issue existence in %s: scan: %w", table, scanErr)
				}
				present[id] = struct{}{}
			}
			_ = rows.Close()
			if err := rows.Err(); err != nil {
				return nil, fmt.Errorf("check issue existence in %s: rows: %w", table, err)
			}
		}
	}
	return present, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect the wrapped driver error for the root cause and address it (connectivity, permissions, schema).
  2. Retry transient failures (deadlock, connection reset) with backoff.
  3. Run schema migrations to ensure the issues table exists.
  4. Raise the context timeout or fix upstream cancellation of the operation.
Defensive patterns

Strategy: retry

Validate before calling

// Probe schema first:
// SELECT COUNT(*) FROM issues — run migrations if this fails.

Try / catch

res, err := ExecuteEdgeRead(ctx, tx, req)
if err != nil && strings.Contains(err.Error(), "check issue existence in ") {
	if isTransient(err) {
		res, err = ExecuteEdgeRead(ctx, tx, req) // retry with fresh tx/backoff
	}
}

Prevention

When it happens

Trigger: ExecuteEdgeRead or ExecuteEdgeCount running while the connection drops, the context is cancelled, or the issues table is missing/corrupt/locked; batched IN probes over a database undergoing migration.

Common situations: Dolt server restart mid-query; context deadline exceeded on large batches; schema where issues was renamed; table corruption or lock contention during concurrent writes.

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/69afb1fd5baadedc. Report an issue: GitHub.