{"record":{"id":"efa8958de155e46d","repo":"SeaQL/sea-orm","slug":"failed-to-get-string-efa895","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_postgres.rs","lineNumber":545,"sourceCode":"                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"FLOAT8[]\" | \"DOUBLE PRECISION[]\" => Value::Array(\n                            sea_query::ArrayType::Double,\n                            row.try_get::<Option<Vec<f64>>, _>(c.ordinal())\n                                .expect(\"Failed to get double array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Double(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"VARCHAR[]\" | \"CHAR[]\" | \"TEXT[]\" | \"NAME[]\" => Value::Array(\n                            sea_query::ArrayType::String,\n                            row.try_get::<Option<Vec<String>>, _>(c.ordinal())\n                                .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\"),","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L527-L563","documentation":"This panic comes from `.expect(\"Failed to get string\")` in `ProxyRow`, where a Postgres VARCHAR/CHAR/TEXT/NAME column is decoded via `row.try_get::<Option<String>>`. It fires when sqlx cannot decode the column's value into a UTF-8 string -- most commonly because the runtime column type OID is not a text-family type (e.g. the column was changed to BYTEA, a numeric, or a custom type) or the bytes are not valid UTF-8 (e.g. a `bytea` or `char(n)` with invalid encoding). `expect` escalates the driver error to a panic.","triggerScenarios":"Any SeaORM query whose result includes a column matched as VARCHAR/CHAR/TEXT/NAME that cannot be decoded as Option<String>: actual column type changed (e.g. to BYTEA or CITEXT-like extension types), database encoding is not UTF-8-compatible for the value, or a view returns a non-text type under a text-named column.","commonSituations":"`ALTER COLUMN ... TYPE BYTEA` or type changed for storage reasons while the model still says String. Non-UTF8 server encoding (e.g. SQL_ASCII/Latin1) with binary data in text columns. Reading via views or FDWs with remapped types. sqlx/sea-orm version skew.","solutions":["Check the actual column type and server encoding (`\\d table`, `SHOW server_encoding`); align the entity field or fix the data encoding.","Cast in the query: `SELECT col::TEXT AS col` so decode receives a text value.","If data is truly binary, map the field to Vec<u8> (Bytes) instead of String.","Align sea-orm/sqlx versions and confirm the `sqlx-postgres` feature set is intact."],"exampleFix":"// before: model expects String but the column holds binary data\npub payload: String,\n\n// after: map the BYTEA column to bytes\npub payload: Vec<u8>,","handlingStrategy":"validation","validationCode":"let rows: Vec<(String, String)> = sqlx::query_as(\n    \"SELECT column_name, data_type FROM information_schema.columns WHERE table_name = $1\"\n).bind(\"my_table\").fetch_all(&db).await?;\nfor (name, ty) in rows {\n    if [\"name\", \"title\"].contains(&name.as_str()) {\n        assert!(matches!(ty.as_str(), \"character varying\" | \"character\" | \"text\" | \"name\"), \"{} has unexpected type {}\", name, ty);\n    }\n}","typeGuard":"fn as_string(v: &sea_orm::Value) -> Option<String> {\n    match v {\n        sea_orm::Value::String(s) => s.clone(),\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["Ensure the database uses UTF8 encoding (SHOW server_encoding) and never store binary data in text columns.","Map BYTEA columns to Vec<u8>, not String, in entities.","Verify column types after migrations or view changes touching text fields.","Use ::TEXT casts in raw SQL for uncertain text columns."],"tags":["postgres","sqlx","type-mismatch","utf-8","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"}