clockworklabs/SpacetimeDB · error
Failed to convert 'scheduled_at' to ScheduleAt
Error message
Failed to convert 'scheduled_at' to ScheduleAt: {e:?} What it means
For each row in a scheduled table, read_schedule_at converts the scheduled_at column from its stored AlgebraicValue into the ScheduleAt sum type (time or interval) via ScheduleAt::try_from. Failure means the stored value's type or shape does not match ScheduleAt, and the conversion error is embedded as {e:?}.
Solutions
- Declare scheduled_at using the SDK-provided ScheduleAt type, never a raw int or string.
- Republish with the corrected schema so the table is rebuilt.
- Delete or fix rows holding incompatible values, then restart the scheduler.
- Align SDK and host versions so encodings match.
Example fix
// before (module schema, Rust)
#[spacetimedb::table(scheduled)]
pub struct Reminder {
pub scheduled_at: i64, // wrong type
}
// after
#[spacetimedb::table(scheduled)]
pub struct Reminder {
#[scheduled_at]
pub scheduled_at: ScheduleAt,
} Defensive patterns
Strategy: validation
Validate before calling
let ty = db.column_type(&tx, table_id, at_column)?;
if !matches_schedule_at_type(&ty) {
return Err(anyhow::anyhow!("scheduled_at column has the wrong type; expected ScheduleAt"));
} Prevention
- Always use the SDK's ScheduleAt type for scheduled_at columns.
- Never insert into scheduled tables with raw SQL that bypasses the module.
- Re-verify scheduled tables after SDK upgrades.
When it happens
Trigger: The scheduled_at column was declared with a type other than the SDK's ScheduleAt; a row was inserted with a mismatched raw value; schema drift after SDK/host changes altered the expected representation.
Common situations: Hand-defined column types in a scheduled table; a module built with an SDK whose ScheduleAt encoding differs from the host's; corrupted rows after a restore.
Related errors
- scheduled table doesn't have valid columns
- failed to typecheck args
- Invalid UUID: must be between 0 and `MAX_UUID_BIGINT`
- Reducer ` ` not found
- ReschemaEventTable: table
AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-09-13).
Data as JSON: /api/errors/2e4f9f4308487bba.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/scheduler.rs:1057
/// 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))
}
pub(super) fn scheduled_row_hash(row: &RowRef<'_>) -> anyhow::Result<Hash> {
Ok(hash_bytes(row.to_bsatn_vec()?))
}
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:?}"))
}
#[cfg(test)]
mod tests {
use super::*;
fn ts(micros: i64) -> Timestamp {
Timestamp::from_micros_since_unix_epoch(micros)
}
#[test]
fn next_interval_tick_uses_last_intended_tick_when_current() {
let next = next_interval_tick_after(ts(1_000), TimeDuration::from_micros(100), ts(1_000));
assert_eq!(next, ts(1_100));
}
#[test]
fn next_interval_tick_skips_missed_ticks() {View on GitHub (pinned to fdd647dfac)