SeaQL/sea-orm · error
Failed to get ip address array
Error message
Failed to get ip address array
What it means
For INET[]/CIDR[] columns, ProxyRow calls row.try_get::<Option<Vec<ipnetwork::IpNetwork>>, _> with .expect("Failed to get ip address array"), panicking on sqlx decode failure. The value is not decodable as an array of IpNetwork — typically it is not a real inet[]/cidr[] on the wire or the ipnetwork codec version mismatches sqlx.
Source
Thrown at src/driver/sqlx_postgres.rs:685
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::Json(Some(Box::new(val))))
.collect(),
)
}),
),
#[cfg(feature = "with-ipnetwork")]
"INET" | "CIDR" => Value::IpNetwork(
row.try_get::<Option<ipnetwork::IpNetwork>, _>(c.ordinal())
.expect("Failed to get ip address"),
),
#[cfg(feature = "with-ipnetwork")]
"INET[]" | "CIDR[]" => Value::Array(
sea_query::ArrayType::IpNetwork,
row.try_get::<Option<Vec<ipnetwork::IpNetwork>>, _>(c.ordinal())
.expect("Failed to get ip address array")
.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())View on GitHub (pinned to e29bcd1b41)
Solutions
- Confirm the true type (udt_name like _inet/_cidr) and ALTER to genuine inet[] if needed.
- Pin one ipnetwork version consistent with sqlx (cargo tree -i ipnetwork).
- Cast in SQL: SELECT my_col::inet[] AS my_col.
- Replace .expect with error mapping for a diagnosable failure.
Example fix
// before
.expect("Failed to get ip address array")
// after
.map_err(|e| DbErr::TryIntoError { value_type: "inet[]".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("allowed_ips").fetch_one(&pool).await?;
assert!(udt.0 == "_inet" || udt.0 == "_cidr", "not an inet[]/cidr[]: {}", udt.0); Type guard
fn is_ip_array(udt_name: &str) -> bool { matches!(udt_name, "_inet" | "_cidr") } Prevention
- Use real inet[]/cidr[] columns rather than text arrays
- Unify ipnetwork versions across the dependency graph
- Cast to ::inet[] in queries against views or foreign tables
- Avoid domains over array types in proxy-read schemas
When it happens
Trigger: A query selecting a column reported as "INET[]"/"CIDR[]" whose value is scalar inet, text[], or a domain over the array; requires the with-ipnetwork feature.
Common situations: Migration changed element type; FDW/view reports wrong array OIDs; duplicate ipnetwork versions after a Cargo update break the Vec decode.
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
- Failed to get mac address array
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/b15bdd21b9273f54.
Report an issue: GitHub.