SeaQL/sea-orm · error
Failed to get mac address array
Error message
Failed to get mac address array
What it means
For MACADDR[]/MACADDR8[] columns, ProxyRow calls row.try_get::<Option<Vec<mac_address::MacAddress>>, _> with .expect("Failed to get mac address array"), panicking on sqlx decode failure. The value is not decodable as an array of MacAddress — the wire type differs from macaddr[]/macaddr8[] or the mac_address codec version mismatches sqlx.
Source
Thrown at src/driver/sqlx_postgres.rs:704
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::IpNetwork(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-mac_address")]
"MACADDR" | "MACADDR8" => Value::MacAddress(
row.try_get::<Option<mac_address::MacAddress>, _>(c.ordinal())
.expect("Failed to get mac address"),
),
#[cfg(all(feature = "with-mac_address", feature = "postgres-array"))]
"MACADDR[]" | "MACADDR8[]" => Value::Array(
sea_query::ArrayType::MacAddress,
row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())
.expect("Failed to get mac address array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::MacAddress(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-chrono")]
"TIMESTAMP" => Value::ChronoDateTime(
row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())
.expect("Failed to get timestamp"),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIMESTAMP" => Value::TimeDateTime(
row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())
.expect("Failed to get timestamp"),View on GitHub (pinned to e29bcd1b41)
Solutions
- Verify udt_name is _macaddr/_macaddr8 and ALTER to a genuine macaddr[] otherwise.
- Unify mac_address crate versions with cargo tree -i mac_address.
- Cast in SQL: SELECT my_col::macaddr[] AS my_col.
- Propagate the decode error as DbErr instead of panicking.
Example fix
// before
.expect("Failed to get mac address array")
// after
.map_err(|e| DbErr::TryIntoError { value_type: "mac_address[]".into(), source: e.into() })? Defensive patterns
Strategy: validation
Validate before calling
let udt: (String,) = sqlx::query_as(
"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2",
)
.bind("my_table").bind("macs").fetch_one(&pool).await?;
assert!(udt.0 == "_macaddr" || udt.0 == "_macaddr8", "not a macaddr[]: {}", udt.0); Type guard
fn is_mac_array(udt_name: &str) -> bool { matches!(udt_name, "_macaddr" | "_macaddr8") } Prevention
- Use genuine macaddr[] columns instead of text arrays of MACs
- Enable with-mac_address plus postgres-array features together
- Cast to ::macaddr[] for views reporting text element types
- Unify mac_address crate versions before upgrading sqlx
When it happens
Trigger: Selecting a column reported as "MACADDR[]" whose value is scalar macaddr, text[], or a domain-over-array; needs both with-mac_address and postgres-array features.
Common situations: Schema drift after migration; views/FDWs reporting wrong element type OIDs; split mac_address crate versions after dependency changes.
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 oid array
- Failed to get json array
- Failed to get ip address array
- Failed to get mac address
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/19852ab9468edd97.
Report an issue: GitHub.