{"record":{"id":"19852ab9468edd97","repo":"SeaQL/sea-orm","slug":"failed-to-get-mac-address-array-19852a","errorCode":null,"errorMessage":"Failed to get mac address array","messagePattern":"Failed to get mac address array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":704,"sourceCode":"                                .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())\n                                .expect(\"Failed to get mac address array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::MacAddress(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMP\" => Value::ChronoDateTime(\n                            row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMESTAMP\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L686-L722","documentation":"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.","triggerScenarios":"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.","commonSituations":"Schema drift after migration; views/FDWs reporting wrong element type OIDs; split mac_address crate versions after dependency changes.","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."],"exampleFix":"// before\n.expect(\"Failed to get mac address array\")\n// after\n.map_err(|e| DbErr::TryIntoError { value_type: \"mac_address[]\".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(\"macs\").fetch_one(&pool).await?;\nassert!(udt.0 == \"_macaddr\" || udt.0 == \"_macaddr8\", \"not a macaddr[]: {}\", udt.0);","typeGuard":"fn is_mac_array(udt_name: &str) -> bool { matches!(udt_name, \"_macaddr\" | \"_macaddr8\") }","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","sqlx","postgres","mac-address","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-14T05:17:10.506Z"}