clockworklabs/SpacetimeDB · error

Failed to convert 'scheduled_at' to ScheduleAt: {e:?}

Error message

Failed to convert 'scheduled_at' to ScheduleAt: {e:?}

What it means

Rows in scheduled tables store their fire time in the schedule-at column as a ScheduleAt sum value (Time or Interval). read_schedule_at reads that column as an AlgebraicValue and converts it with ScheduleAt::try_from; if the stored value's type does not match the expected algebraic sum type, conversion fails with this error. The column's contents no longer have the shape the scheduler expects.

Source

Thrown at crates/core/src/host/scheduler.rs:903

        .next())
}

/// Helper to get `schedule_id` and `schedule_at`
/// from `schedule_row` product value.
pub fn get_schedule_from_row(
    row: &RowRef<'_>,
    id_column: ColId,
    at_column: ColId,
) -> anyhow::Result<(u64, ScheduleAt)> {
    let schedule_id: u64 = row.read_col(id_column)?;
    let schedule_at = read_schedule_at(row, at_column)?;

    Ok((schedule_id, schedule_at))
}

fn read_schedule_at(row: &RowRef<'_>, at_column: ColId) -> anyhow::Result<ScheduleAt> {
    let schedule_at_av: AlgebraicValue = row.read_col(at_column)?;
    ScheduleAt::try_from(schedule_at_av).map_err(|e| anyhow!("Failed to convert 'scheduled_at' to ScheduleAt: {e:?}"))
}

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Revert or fix the column-type change so the at column is the SDK-generated schedule-at type, then republish.
  2. Delete or rewrite offending rows so the column contains valid Time or Interval values.
  3. Recreate the scheduled table via a clean publish if the data is disposable.
  4. Stop writing to scheduled tables manually; insert only through the SDK's scheduling APIs.

Example fix

// before: raw numeric timestamp written into the schedule-at column
row.scheduled_at = 1_700_000_000u64;

// after: write a proper ScheduleAt value via the SDK API
row.scheduled_at = schedule_at_time(Duration::from_secs(1_700_000_000));
Defensive patterns

Strategy: validation

Validate before calling

// Only write schedule times through the SDK value type
// and validate existing rows after a schema-touching upgrade:
for row in scheduled_table.iter() {
    ScheduleAt::try_from(row.scheduled_at.clone())?; // must convert before the scheduler reads it
}

Prevention

When it happens

Trigger: The at-column holds a value of a different algebraic type than ScheduleAt: schema drift after changing the column type between publishes, rows written by an older SDK encoding, or corrupted/manually inserted rows in a scheduled table.

Common situations: Changing a scheduled table's column types in a module update; mixing rows written by different SDK versions; direct database edits or imports that bypass the SDK's encoding.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/2e4f9f4308487bba. Report an issue: GitHub.