{"record":{"id":"c0f893a89f6beb38","repo":"SeaQL/sea-orm","slug":"failed-to-get-bytes-c0f893","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_sqlite.rs","lineNumber":438,"sourceCode":"                        }\n\n                        \"BIGINT\" | \"INT8\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n                        ),\n\n                        \"REAL\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n\n                        \"TEXT\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\")\n                                .map(Box::new),\n                        ),\n\n                        \"BLOB\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATETIME\" => {\n                            use chrono::{DateTime, Utc};\n\n                            Value::ChronoDateTimeUtc(\n                                row.try_get::<Option<DateTime<Utc>>, _>(c.ordinal())\n                                    .expect(\"Failed to get timestamp\")\n                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATETIME\" => {\n                            use time::OffsetDateTime;\n                            Value::TimeDateTimeWithTimeZone(\n                                row.try_get::<Option<OffsetDateTime>, _>(c.ordinal())","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L420-L456","documentation":"Panic when sea-orm-sync's SQLite driver cannot decode a \"BLOB\" column into Option<Vec<u8>> while building a ProxyRow. sqlx fails when the physical value under a BLOB-typed column is not actually a blob (TEXT/INTEGER/REAL storage class), since SQLite's typing is per-value, not per-column.","triggerScenarios":"Reading a BLOB column whose stored value is text or numeric storage class, or any sqlx decode error on that column while the type_info reports \"BLOB\".","commonSituations":"Binary data inserted as hex/text strings by another tool; columns declared BLOB but storing serialized JSON as text; mixed storage after imports from other databases.","solutions":["Check storage classes (SELECT typeof(col)) and convert: UPDATE t SET col = CAST(col AS BLOB) WHERE typeof(col) != 'blob'","Insert binary data through typed entity models with Vec<u8> fields rather than raw SQL strings","If values are legitimately text, fix the column type declaration or the match arm so TEXT columns decode as strings","Propagate the sqlx error with column context instead of .expect"],"exampleFix":"// before\n\"BLOB\" => 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\"BLOB\" => Value::Bytes(\n    row.try_get::<Option<Vec<u8>>, _>(c.ordinal())\n        .unwrap_or_else(|e| panic!(\"Failed to get bytes for col {}: {}\", c.name(), e))\n        .map(Box::new),\n)","handlingStrategy":"validation","validationCode":"// Verify BLOB columns hold blob storage class:\n// SELECT typeof(col), count(*) FROM t GROUP BY typeof(col);","typeGuard":"fn is_blob_storage(type_of: &str) -> bool { type_of == \"blob\" }","tryCatchPattern":"let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());","preventionTips":["Insert binary data as Vec<u8> through typed entity fields","CAST text values to BLOB when needed","Never store hex/text-encoded binary in BLOB columns","Audit storage classes before ProxyRow reads"],"tags":["rust","sqlx","sqlite","blob","bytes","type-conversion","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"}