{"record":{"id":"701c55954eed2a2d","repo":"SeaQL/sea-orm","slug":"failed-to-get-string","errorCode":null,"errorMessage":"Failed to get string","messagePattern":"Failed to get string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":438,"sourceCode":"                        ),\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\")))]\n                        \"TIMESTAMP\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L420-L456","documentation":"This panic comes from `.expect(\"Failed to get string\")` in `ProxyRow`'s MySQL driver conversion. `sqlx::Row::try_get::<Option<String>, _>` failed for a CHAR/VARCHAR/TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT column at `c.ordinal()`. Because the code uses `expect`, the decode failure panics instead of returning an error. It usually means the column is not actually a text type or the value cannot be decoded as UTF-8-compatible String.","triggerScenarios":"Reading a MySQL text-type column whose value fails String decoding — commonly after the column was altered to BLOB/BINARY or JSON while cached metadata still says CHAR/VARCHAR/TEXT, or invalid character encodings sqlx cannot map to String.","commonSituations":"Metadata captured before an ALTER TABLE; columns created with binary collations; MySQL server/connector charset mismatches (e.g. latin1 vs utf8mb4) causing decode failures.","solutions":["Refresh the table metadata so the text-type mapping matches the live schema.","Verify the column is a character type and uses a text collation; convert binary columns before reading them as strings.","Ensure consistent charset configuration (utf8mb4) across server, connection, and sqlx version.","Change the driver to return DbErr instead of `expect` so the underlying sqlx decode error is visible."],"exampleFix":"// before\n\"CHAR\" | \"VARCHAR\" | ... | \"LONGTEXT\" => Value::String(\n    row.try_get::<Option<String>, _>(c.ordinal())\n        .expect(\"Failed to get string\")\n        .map(Box::new),\n)\n// after\n... => Value::String(\n    row.try_get::<Option<String>, _>(c.ordinal())\n        .map_err(|e| DbErr::TryGetErr(...))? // propagate instead of panicking\n        .map(Box::new),\n)","handlingStrategy":"validation","validationCode":"// Verify the column is a text type with a text collation before reading as String\nlet col = table_columns.iter().find(|c| c.name == \"my_col\").expect(\"column missing\");\nconst TEXT_TYPES: &[&str] = &[\"CHAR\", \"VARCHAR\", \"TINYTEXT\", \"TEXT\", \"MEDIUMTEXT\", \"LONGTEXT\"];\nassert!(TEXT_TYPES.contains(&col.type_name.as_str()), \"expected text column, got {}\", col.type_name);","typeGuard":null,"tryCatchPattern":"// The panic originates in the driver; wrap the boundary:\nstd::panic::catch_unwind(|| proxy_row_from(&row, &columns))\n    .map_err(|_| DbErr::Custom(\"text column decode failed\".into()))?","preventionTips":["Use a consistent charset (utf8mb4) across server, connection, and driver configuration.","Refresh metadata after any ALTER TABLE affecting text columns.","Avoid binary collations on columns you intend to read as strings.","Watch for dependency trees mixing sea-orm/sea-orm-sync versions with different feature flags."],"tags":["mysql","sqlx","string-decoding","charset","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"}