{"record":{"id":"64c09975e8f24063","repo":"SeaQL/sea-orm","slug":"failed-to-get-bytes-array-64c099","errorCode":null,"errorMessage":"Failed to get bytes array","messagePattern":"Failed to get bytes array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":582,"sourceCode":"                                .expect(\"Failed to get string array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::String(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"BYTEA\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"BYTEA[]\" => Value::Array(\n                            sea_query::ArrayType::Bytes,\n                            row.try_get::<Option<Vec<Vec<u8>>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Bytes(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-bigdecimal\")]\n                        \"NUMERIC\" => Value::BigDecimal(\n                            row.try_get::<Option<bigdecimal::BigDecimal>, _>(c.ordinal())\n                                .expect(\"Failed to get numeric\"),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\")\n                        ))]","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L564-L600","documentation":"This panic originates from `.expect(\"Failed to get bytes array\")` in ProxyRow (src/driver/sqlx_postgres.rs:582). For BYTEA[] columns (behind `postgres-array`), the code decodes `Option<Vec<Vec<u8>>>`; failure to decode into that type panics. Usually the value isn't a bytea array, its element type differs, or array support wasn't enabled in sqlx.","triggerScenarios":"Reading bytea[] produced by array_agg over bytea in an sqlx version lacking array-of-bytea decode support, a column actually holding scalar bytea or text[], or type-name metadata reporting BYTEA[] for a mismatched underlying type.","commonSituations":"Missing `postgres-array` feature, sqlx/sea-orm version skew after upgrade, schema drift, or extension-generated arrays with nonstandard element OIDs.","solutions":["Enable `postgres-array` on both sea-orm and sqlx and rebuild.","Verify the type with `SELECT array_typeof(col)` and cast in SQL: `col::bytea[]`.","Upgrade or pin sea-orm/sqlx to compatible versions with bytea-array decoding support.","Capture the underlying sqlx error with RUST_LOG=sqlx=debug before the panic point.","Convert the expect into a DbErr::Custom error including the column ordinal."],"exampleFix":"// before\nrow.try_get::<Option<Vec<Vec<u8>>>, _>(c.ordinal()).expect(\"Failed to get bytes array\")\n// after\nrow.try_get::<Option<Vec<Vec<u8>>>, _>(c.ordinal())\n    .map_err(|e| DbErr::Custom(format!(\"bytea[] decode failed col {}: {e}\", c.ordinal())))?","handlingStrategy":"validation","validationCode":"// Verify bytea[] elements:\n// SELECT array_typeof(col) FROM t LIMIT 1;  -- expect 'bytea'\n// Or cast: SELECT col::bytea[] FROM ...","typeGuard":"fn is_bytea_array_col(c: &ProxyColumn) -> bool {\n    c.ty == \"BYTEA[]\"\n}","tryCatchPattern":"std::panic::catch_unwind(|| read_row(row))\n    .map_err(|p| DbErr::Custom(format!(\"bytea[] decode panic: {p:?}\")))?;","preventionTips":["Enable `postgres-array` on sea-orm and sqlx.","Cast to ::bytea[] when the element type is uncertain.","Verify your sqlx version supports decoding arrays of bytea.","Check array_typeof in data validation.","Keep dependencies on compatible versions."],"tags":["postgres","sqlx","array","bytes","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}