{"record":{"id":"b15bdd21b9273f54","repo":"SeaQL/sea-orm","slug":"failed-to-get-ip-address-array-b15bdd","errorCode":null,"errorMessage":"Failed to get ip address array","messagePattern":"Failed to get ip address array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":685,"sourceCode":"                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Json(Some(Box::new(val))))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-ipnetwork\")]\n                        \"INET\" | \"CIDR\" => Value::IpNetwork(\n                            row.try_get::<Option<ipnetwork::IpNetwork>, _>(c.ordinal())\n                                .expect(\"Failed to get ip address\"),\n                        ),\n                        #[cfg(feature = \"with-ipnetwork\")]\n                        \"INET[]\" | \"CIDR[]\" => Value::Array(\n                            sea_query::ArrayType::IpNetwork,\n                            row.try_get::<Option<Vec<ipnetwork::IpNetwork>>, _>(c.ordinal())\n                                .expect(\"Failed to get ip address array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::IpNetwork(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-mac_address\")]\n                        \"MACADDR\" | \"MACADDR8\" => Value::MacAddress(\n                            row.try_get::<Option<mac_address::MacAddress>, _>(c.ordinal())\n                                .expect(\"Failed to get mac address\"),\n                        ),\n                        #[cfg(all(feature = \"with-mac_address\", feature = \"postgres-array\"))]\n                        \"MACADDR[]\" | \"MACADDR8[]\" => Value::Array(\n                            sea_query::ArrayType::MacAddress,\n                            row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L667-L703","documentation":"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.","triggerScenarios":"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.","commonSituations":"Migration changed element type; FDW/view reports wrong array OIDs; duplicate ipnetwork versions after a Cargo update break the Vec decode.","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."],"exampleFix":"// before\n.expect(\"Failed to get ip address array\")\n// after\n.map_err(|e| DbErr::TryIntoError { value_type: \"inet[]\".into(), source: e.into() })?","handlingStrategy":"validation","validationCode":"let udt: (String,) = sqlx::query_as(\n    \"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\",\n)\n.bind(\"my_table\").bind(\"allowed_ips\").fetch_one(&pool).await?;\nassert!(udt.0 == \"_inet\" || udt.0 == \"_cidr\", \"not an inet[]/cidr[]: {}\", udt.0);","typeGuard":"fn is_ip_array(udt_name: &str) -> bool { matches!(udt_name, \"_inet\" | \"_cidr\") }","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","sqlx","postgres","ipnetwork","array"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}