SeaQL/sea-orm · error
Failed to get uuid
Error message
Failed to get uuid
What it means
This panic occurs in sea-orm-sync's PostgreSQL driver when converting a raw sqlx row into a ProxyRow. For a column whose declared type is "UUID", the code calls row.try_get::<Option<uuid::Uuid>>() and .expect()s success, so any sqlx decode error (or unexpected null handling mismatch) aborts the process instead of returning a Result.
Source
Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:915
feature = "postgres-array"
))]
"TIMETZ[]" => Value::Array(
sea_query::ArrayType::TimeTime,
row.try_get::<Option<Vec<time::Time>>, _>(c.ordinal())
.expect("Failed to get timetz array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::TimeTime(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-uuid")]
"UUID" => Value::Uuid(
row.try_get::<Option<uuid::Uuid>, _>(c.ordinal())
.expect("Failed to get uuid"),
),
#[cfg(all(feature = "with-uuid", feature = "postgres-array"))]
"UUID[]" => Value::Array(
sea_query::ArrayType::Uuid,
row.try_get::<Option<Vec<uuid::Uuid>>, _>(c.ordinal())
.expect("Failed to get uuid array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::Uuid(Some(val)))
.collect(),
)
}),
),
_ => unreachable!("Unknown column type: {}", c.type_info().name()),
},View on GitHub (pinned to e29bcd1b41)
Solutions
- Check the actual stored value and column type in Postgres (\d table / SELECT ::text) to confirm it is a valid 16-byte uuid value
- Align the entity/ProxyRow decode path with the real column type so the match arm matches the true type_info name
- Pin compatible sqlx and uuid crate versions (sqlx's uuid feature vs uuid crate major version)
- If you control the code, replace .expect with proper error propagation and fall back to Value::String for undecodable values
Example fix
// before
"UUID" => Value::Uuid(
row.try_get::<Option<uuid::Uuid>, _>(c.ordinal())
.expect("Failed to get uuid"),
),
// after
"UUID" => Value::Uuid(
row.try_get::<Option<uuid::Uuid>, _>(c.ordinal())
.unwrap_or_else(|e| panic!("Failed to get uuid for col {} ({}): {}", c.name(), c.type_info().name(), e)),
), Defensive patterns
Strategy: validation
Validate before calling
// Before reading UUID columns, verify stored values are valid uuids:
// SELECT col::text FROM t WHERE col IS NOT NULL AND col::text !~ '^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$';
fn is_uuid_column(type_name: &str) -> bool { type_name == "UUID" } Type guard
fn decode_uuid(v: Option<uuid::Uuid>) -> Option<uuid::Uuid> { v } Try / catch
// ProxyRow panics rather than returning Result; catch at the query boundary in an app: let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());
Prevention
- Confirm column types with \d before mapping them as UUID in ProxyRow
- Use typed entity models instead of raw ProxyRow reads for uuid columns
- Pin matching sqlx/uuid crate versions
- Add a smoke test reading a sample row of every uuid column at deploy time
When it happens
Trigger: Querying a Postgres UUID column via ProxyRow when the actual value cannot be decoded into Option<uuid::Uuid> — e.g. the value is NULL but the runtime type info says UUID and the non-Option path is taken, the column type string mismatches the stored value, or the uuid feature's decode fails on a malformed UUID stored as text.
Common situations: Reading a UUID column that was written by another tool as a plain text value with different formatting; schema drift where a column was ALTERed from uuid to text/varchar but cached metadata still reports "UUID"; using an older sqlx/uuid version pair with incompatible decoding.
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 uuid array
- 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/94b1fdf32144ad37.
Report an issue: GitHub.