{"record":{"id":"4abd9c074b0d7f75","repo":"SeaQL/sea-orm","slug":"failed-to-get-bytes","errorCode":null,"errorMessage":"Failed to get bytes","messagePattern":"Failed to get bytes","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":431,"sourceCode":"                                .expect(\"Failed to get small integer\"),\n                        ),\n                        \"INT\" => {\n                            Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n                        }\n                        \"MEDIUMINT\" | \"BIGINT\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n                        ),\n                        \"FLOAT\" => {\n                            Value::Float(row.try_get(c.ordinal()).expect(\"Failed to get float\"))\n                        }\n                        \"DOUBLE\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n\n                        \"BIT\" | \"BINARY\" | \"VARBINARY\" | \"TINYBLOB\" | \"BLOB\" | \"MEDIUMBLOB\"\n                        | \"LONGBLOB\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\")\n                                .map(Box::new),\n                        ),\n\n                        \"CHAR\" | \"VARCHAR\" | \"TINYTEXT\" | \"TEXT\" | \"MEDIUMTEXT\" | \"LONGTEXT\" => {\n                            Value::String(\n                                row.try_get::<Option<String>, _>(c.ordinal())\n                                    .expect(\"Failed to get string\")\n                                    .map(Box::new),\n                            )\n                        }\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMP\" => Value::ChronoDateTimeUtc(\n                            row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L413-L449","documentation":"This panic originates from `.expect(\"Failed to get bytes\")` in `ProxyRow`'s MySQL driver row conversion. It means `sqlx::Row::try_get::<Option<Vec<u8>>, _>` failed for a BIT/BINARY/VARBINARY/TINYBLOB/BLOB/MEDIUMBLOB/LONGBLOB column at the given ordinal. The library panics because this conversion is treated as infallible; failure signals a real mismatch between the column's declared type and the value sqlx returned. NULLs are handled (Option), so the error is about decoding, not nullability.","triggerScenarios":"Reading a MySQL binary-type column (BIT, BINARY, VARBINARY, or any BLOB) whose value cannot be decoded as `Option<Vec<u8>>` — e.g. metadata captured before a column type change, or BIT columns with widths sqlx returns as different types.","commonSituations":"Schema drift after altering a BLOB column to TEXT or JSON; BIT(1) columns treated as boolean by other tools; driver version differences in how MySQL BIT values are returned.","solutions":["Refresh table metadata so the column's declared type string matches the live schema (`SHOW CREATE TABLE`).","Confirm the column is a binary type; if it was changed to TEXT/JSON, ensure the driver maps it under the string branch instead.","Check sqlx MySQL driver version — BIT decoding behavior varies; align versions.","Patch the driver to propagate a DbErr rather than panicking, so failures are diagnosable at runtime."],"exampleFix":"// before\n\"BIT\" | \"BINARY\" | \"VARBINARY\" | ... | \"LONGBLOB\" => Value::Bytes(\n    row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n        .expect(\"Failed to get bytes\")\n        .map(Box::new),\n)\n// after\n... => Value::Bytes(\n    row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n        .map_err(|e| DbErr::TryGetErr(...))? // propagate instead of panicking\n        .map(Box::new),\n)","handlingStrategy":"validation","validationCode":"// Ensure the column is a binary type before reading it as Bytes\nlet col = table_columns.iter().find(|c| c.name == \"my_col\").expect(\"column missing\");\nconst BINARY_TYPES: &[&str] = &[\"BIT\", \"BINARY\", \"VARBINARY\", \"TINYBLOB\", \"BLOB\", \"MEDIUMBLOB\", \"LONGBLOB\"];\nassert!(BINARY_TYPES.contains(&col.type_name.as_str()), \"expected binary column\");","typeGuard":null,"tryCatchPattern":"// Driver panics on decode failure; contain it at the call boundary:\nstd::panic::catch_unwind(|| proxy_row_from(&row, &columns))\n    .map_err(|_| DbErr::Custom(\"binary column decode failed\".into()))?","preventionTips":["Never let BLOB columns be altered to TEXT/JSON without refreshing driver metadata.","Check how your MySQL driver version returns BIT values (bit vs byte representation).","Keep sqlx versions aligned across the workspace.","Add CI checks that run row proxying against the real schema."],"tags":["mysql","sqlx","binary-data","type-decoding","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-14T05:17:10.506Z"}