{"record":{"id":"2e4f9f4308487bba","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-convert-scheduled-at-to-scheduleat-e","errorCode":null,"errorMessage":"Failed to convert 'scheduled_at' to ScheduleAt: {e:?}","messagePattern":"Failed to convert 'scheduled_at' to ScheduleAt: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/scheduler.rs","lineNumber":1057,"sourceCode":"/// from `schedule_row` product value.\npub fn get_schedule_from_row(\n    row: &RowRef<'_>,\n    id_column: ColId,\n    at_column: ColId,\n) -> anyhow::Result<(u64, ScheduleAt)> {\n    let schedule_id: u64 = row.read_col(id_column)?;\n    let schedule_at = read_schedule_at(row, at_column)?;\n\n    Ok((schedule_id, schedule_at))\n}\n\npub(super) fn scheduled_row_hash(row: &RowRef<'_>) -> anyhow::Result<Hash> {\n    Ok(hash_bytes(row.to_bsatn_vec()?))\n}\n\nfn read_schedule_at(row: &RowRef<'_>, at_column: ColId) -> anyhow::Result<ScheduleAt> {\n    let schedule_at_av: AlgebraicValue = row.read_col(at_column)?;\n    ScheduleAt::try_from(schedule_at_av).map_err(|e| anyhow!(\"Failed to convert 'scheduled_at' to ScheduleAt: {e:?}\"))\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn ts(micros: i64) -> Timestamp {\n        Timestamp::from_micros_since_unix_epoch(micros)\n    }\n\n    #[test]\n    fn next_interval_tick_uses_last_intended_tick_when_current() {\n        let next = next_interval_tick_after(ts(1_000), TimeDuration::from_micros(100), ts(1_000));\n        assert_eq!(next, ts(1_100));\n    }\n\n    #[test]\n    fn next_interval_tick_skips_missed_ticks() {","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/core/src/host/scheduler.rs#L1039-L1075","documentation":"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:?}.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (module schema, Rust)\n#[spacetimedb::table(scheduled)]\npub struct Reminder {\n    pub scheduled_at: i64, // wrong type\n}\n\n// after\n#[spacetimedb::table(scheduled)]\npub struct Reminder {\n    #[scheduled_at]\n    pub scheduled_at: ScheduleAt,\n}","handlingStrategy":"validation","validationCode":"let ty = db.column_type(&tx, table_id, at_column)?;\nif !matches_schedule_at_type(&ty) {\n    return Err(anyhow::anyhow!(\"scheduled_at column has the wrong type; expected ScheduleAt\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["scheduled","scheduleat","type-conversion","scheduler"],"backgroundTag":"type-conversion-failed","analyzedSha":"fdd647dfac506d0967cc4492e9fce380706c94cb","analyzedAt":"2026-09-13T15:42:39.379Z","contentChangedAt":"2026-09-13T15:42:39.379Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}