gastownhall/beads · error
get events since %v: %w
Error message
get events since %v: %w
What it means
GetAllEventsSinceInTx selects all wisp events with created_at after the given timestamp, ordered ascending. A query failure at execution time is wrapped with the `since` value included. It means incremental event sync cannot proceed because the wisp_events table could not be read from that point.
Source
Thrown at internal/storage/issueops/events.go:53
return scanEvents(rows)
}
// GetAllEventsSinceInTx returns all events created after the given time,
// querying both events and wisp_events tables.
func GetAllEventsSinceInTx(ctx context.Context, tx *sql.Tx, since time.Time) ([]*types.Event, error) {
rows, err := tx.QueryContext(ctx, `
SELECT id, issue_id, event_type, actor, old_value, new_value, comment, created_at
FROM events
WHERE created_at > ?
UNION ALL
SELECT id, issue_id, event_type, actor, old_value, new_value, comment, created_at
FROM wisp_events
WHERE created_at > ?
ORDER BY created_at ASC
`, since, since)
if err != nil {
return nil, fmt.Errorf("get events since %v: %w", since, err)
}
defer rows.Close()
return scanEvents(rows)
}
// Event keyset-read bounds. The API's change feed pages the durable events
// table with a bounded limit (default when the caller passes <= 0, hard cap
// otherwise).
const (
defaultEventsSinceLimit = 100
maxEventsSinceLimit = 500
)
// EventsSinceInTx returns durable events strictly after the (createdAt, id)
// keyset cursor, ordered by (created_at ASC, id ASC) and bounded by limit.
// issueID != "" scopes the feed to one bead's history; "" returns all issues'.
//View on GitHub (pinned to 71377f2769)
Solutions
- If the wrapped cause is 'no such table: wisp_events', run bd's migrations so wisp tables exist.
- Retry on transient connection errors.
- Ensure `since` is a valid timestamp the driver can bind (time.Time or correct string format).
- Check connectivity to the database and server logs.
Example fix
// before client.GetAllEventsSince(ctx, "2026-08-30 not-a-time") // after client.GetAllEventsSince(ctx, time.Now().Add(-24*time.Hour))
Defensive patterns
Strategy: try-catch
Validate before calling
var hasWisps int
_ = db.QueryRow("SELECT COUNT(*) FROM information_schema.tables WHERE table_name='wisp_events'").Scan(&hasWisps)
if hasWisps == 0 { return errors.New("wisp_events missing; run migrations first") }
if since.IsZero() { return errors.New("since must be a valid timestamp") } Type guard
func isEventsSinceErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "get events since ")
} Try / catch
events, err := GetAllEventsSinceInTx(ctx, tx, since)
if err != nil {
if isEventsSinceErr(err) && strings.Contains(err.Error(), "no such table") {
return migrateThenResync(ctx, since)
}
return fmt.Errorf("incremental event sync failed: %w", err)
} Prevention
- Ensure wisp migrations are applied before incremental sync.
- Always pass a valid time.Time for `since`.
- Persist a high-water mark timestamp for resumable sync.
- Retry transient connection failures with backoff.
When it happens
Trigger: Calling GetAllEventsSinceInTx when the `SELECT ... FROM wisp_events WHERE created_at > ?` query fails — the wisp_events table not existing yet (pre-migration database), a connection error, or an unparseable/invalid since parameter.
Common situations: Running sync against an old database before wisp tables were created; clock/timestamp formats from other tooling causing driver conversion errors; remote Dolt server unreachable.
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/04a5013f611a5da6.
Report an issue: GitHub.