SeaQL/sea-orm · critical
Failed to get time
Error message
Failed to get time
What it means
This panic comes from an `.expect("Failed to get time")` inside the SQLite row-decoding code (src/driver/sqlx_sqlite.rs:494). While converting a raw sqlx row into SeaORM `Value`s, a column declared `TIME` fails `row.try_get::<Option<NaiveTime>, _>()`, meaning the underlying sqlx value could not be decoded into a chrono NaiveTime. The library treats decoding failure as unrecoverable and panics instead of returning a DbErr.
Source
Thrown at src/driver/sqlx_sqlite.rs:494
.map(Box::new),
)
}
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"DATE" => {
use time::Date;
Value::TimeDate(
row.try_get::<Option<Date>, _>(c.ordinal())
.expect("Failed to get date")
.map(Box::new),
)
}
#[cfg(feature = "with-chrono")]
"TIME" => {
use chrono::NaiveTime;
Value::ChronoTime(
row.try_get::<Option<NaiveTime>, _>(c.ordinal())
.expect("Failed to get time")
.map(Box::new),
)
}
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIME" => {
use time::Time;
Value::TimeTime(
row.try_get::<Option<Time>, _>(c.ordinal())
.expect("Failed to get time")
.map(Box::new),
)
}
_ => unreachable!("Unknown column type: {}", c.type_info().name()),
},
)
})
.collect(),View on GitHub (pinned to e29bcd1b41)
Solutions
- Fix the data: correct or NULL out the malformed TIME values stored in the SQLite table.
- Make the Rust model column a String (or ChronoDateTime with a supported format) so decoding matches what is actually stored.
- Ensure the value is stored in a format sqlx's chrono support can decode (e.g. 'HH:MM:SS' text).
- Enable the matching feature flag consistently (`with-chrono` vs `with-time`) so decoding and model types agree.
- Query the column via a cast to TEXT in a raw query instead of relying on typed decoding.
Example fix
// before pub start_time: NaiveTime, // after (if the column stores arbitrary text) #[sea_orm(column_type = "Time")] pub start_time: String,
Defensive patterns
Strategy: validation
Validate before calling
// before fetching, verify the column holds decodable TIME values
let bad: Vec<_> = sqlx::query("SELECT rowid, cast(col AS TEXT) t FROM tbl WHERE col IS NOT NULL AND col GLOB '*[^0-9:. ]*' OR col GLOB '[0-9]*:[0-9]*:*' AND cast(col AS TEXT) > '23:59:59.999999'")
.fetch_all(&pool).await?; if !bad.is_empty() { /* clean up rows */ } Type guard
fn is_valid_sqlite_time(v: &str) -> bool {
time::Time::parse(v, "%H:%M:%S%.f").is_ok()
} Try / catch
// SeaORM panics; isolate the query and convert panic to error if needed
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
entity::Entity::find().all(db)
})); Prevention
- Keep SQLite column storage classes aligned with the entity model's declared types
- Validate imported/migrated data before querying with typed models
- Enable exactly one of with-chrono / with-time and match model field types to it
- Prefer TEXT/INTEGER storage with application-level parsing for heterogeneous legacy data
When it happens
Trigger: Selecting a SQLite `TIME` column (with the `with-chrono` feature) whose stored value cannot be decoded into NaiveTime, e.g. an out-of-range time like '25:00:00', a malformed text value, or a BLOB/INTEGER stored in a column the driver reports as TIME.
Common situations: SQLite is dynamically typed, so columns frequently hold values that don't match the declared schema; hand-inserted rows, data migrated from another tool, or a changed column type after table creation all cause this panic during `find()`/raw query mapping.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to get timestamp
- Failed to get boolean
- Failed to get integer
- Failed to get big integer
- Failed to get double
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/d63d518b6473fde4.
Report an issue: GitHub.