{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/src/host/scheduler.rs","lineNumber":903,"sourceCode":"        .next())\n}\n\n/// Helper to get `schedule_id` and `schedule_at`\n/// 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\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","sourceCodeStart":885,"sourceCodeEnd":905,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/scheduler.rs#L885-L905","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Revert or fix the column-type change so the at column is the SDK-generated schedule-at type, then republish.","Delete or rewrite offending rows so the column contains valid Time or Interval values.","Recreate the scheduled table via a clean publish if the data is disposable.","Stop writing to scheduled tables manually; insert only through the SDK's scheduling APIs."],"exampleFix":"// before: raw numeric timestamp written into the schedule-at column\nrow.scheduled_at = 1_700_000_000u64;\n\n// after: write a proper ScheduleAt value via the SDK API\nrow.scheduled_at = schedule_at_time(Duration::from_secs(1_700_000_000));","handlingStrategy":"validation","validationCode":"// Only write schedule times through the SDK value type\n// and validate existing rows after a schema-touching upgrade:\nfor row in scheduled_table.iter() {\n    ScheduleAt::try_from(row.scheduled_at.clone())?; // must convert before the scheduler reads it\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never insert raw integers into the schedule-at column.","Do not change scheduled-table column types between publishes without a migration plan.","Use the SDK scheduling APIs for all inserts into scheduled tables."],"tags":["scheduler","bsatn","type-conversion","schema-drift"],"backgroundTag":"type-conversion-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}