{"record":{"id":"be00f289893513eb","repo":"SeaQL/sea-orm","slug":"failed-to-get-mac-address-be00f2","errorCode":null,"errorMessage":"Failed to get mac address","messagePattern":"Failed to get mac address","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":698,"sourceCode":"                        ),\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())\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())","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L680-L716","documentation":"ProxyRow decodes MACADDR/MACADDR8 columns into mac_address::MacAddress with .expect(\"Failed to get mac address\"), panicking when sqlx cannot decode. Option handles NULL, so the panic means the wire value isn't a Postgres macaddr/macaddr8 as sqlx expects, or the mac_address crate version sqlx links differs from the one in the dependency graph.","triggerScenarios":"Selecting a column typed \"MACADDR\"/\"MACADDR8\" whose value is stored as text, or a duplicate mac_address crate version breaking FromSql impl matching; requires the with-mac_address feature.","commonSituations":"varchar columns holding MAC strings; Cargo.lock with two mac_address versions after update; reading via a view that returns text.","solutions":["Check the column type is real macaddr/macaddr8 and ALTER ... TYPE macaddr USING col::macaddr if not.","Run cargo tree -i mac_address and unify to a single version sqlx supports.","Cast in the query: SELECT my_col::macaddr AS my_col.","Map the sqlx error to DbErr instead of .expect in driver code."],"exampleFix":"// before\n.expect(\"Failed to get mac address\")\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(\"mac\").fetch_one(&pool).await?;\nassert!(matches!(udt.0.as_str(), \"macaddr\" | \"macaddr8\"), \"not macaddr: {}\", udt.0);","typeGuard":"fn is_mac_type(udt_name: &str) -> bool { matches!(udt_name, \"macaddr\" | \"macaddr8\") }","tryCatchPattern":null,"preventionTips":["Declare MAC columns as macaddr/macaddr8, not varchar","Keep a single mac_address crate version (cargo tree -i mac_address)","Enable the with-mac_address feature where proxy reads happen","Normalize MAC formats on write (Postgres does this for macaddr)"],"tags":["rust","sqlx","postgres","mac-address","panic"],"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"}