{"record":{"id":"c57ab030c0edb0c1","repo":"SeaQL/sea-orm","slug":"failed-to-get-string-c57ab0","errorCode":null,"errorMessage":"Failed to get string","messagePattern":"Failed to get string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":558,"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":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L540-L576","documentation":"This panic is produced by `.expect(\"Failed to get string\")` in ProxyRow's PostgreSQL conversion (src/driver/sqlx_postgres.rs:558). When a column's type name is VARCHAR/CHAR/TEXT/NAME, the driver decodes `Option<String>` from sqlx and panics if decoding fails. This happens when the actual value is not a decodable text type, or the row/column metadata is stale or out of range.","triggerScenarios":"Reading a text-typed column where the underlying data is bytea or another non-text type, querying a view/expression whose returned type no longer matches VARCHAR/TEXT, a custom domain type over text that sqlx can't decode to String, or an out-of-range ordinal due to stale column metadata.","commonSituations":"Schema changed after the proxy cached the column list, citext or custom text domains with missing sqlx support, passing a bytea column mislabeled as TEXT by a shim/driver, or sqlx version mismatch changing how text decoding validates types.","solutions":["Verify the real column type with information_schema.columns and correct the schema or cast (`col::text`) in the query.","Rebuild the query so column metadata (PgTypeInfo) is re-fetched fresh after any ALTER TABLE.","Match sea-orm and sqlx versions and rebuild; decode strictness differs between sqlx versions.","Check whether the column is a custom type/domain (e.g. citext) requiring an sqlx feature or a cast to plain text.","Replace expect with an error mapped to DbErr::Custom that names the column for diagnosis."],"exampleFix":"// before\n\"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\" => Value::String(\n    row.try_get::<Option<String>, _>(c.ordinal()).expect(\"Failed to get string\"),\n)\n// after (cast in SQL to guarantee text)\n// SELECT name::text AS name FROM ...\n\"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\" => Value::String(\n    row.try_get::<Option<String>, _>(c.ordinal())\n        .map_err(|e| DbErr::Custom(format!(\"text decode failed col {}: {e}\", c.ordinal())))?,\n)","handlingStrategy":"validation","validationCode":"// Confirm the column is a text type before reading:\n// SELECT data_type FROM information_schema.columns\n//   WHERE table_name=$1 AND column_name=$2;  -- expect character varying/text/char/name\n// Or cast: SELECT col::text FROM ...","typeGuard":"fn is_text_col(c: &ProxyColumn) -> bool {\n    matches!(c.ty.as_str(), \"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\")\n}","tryCatchPattern":"std::panic::catch_unwind(|| read_row(row))\n    .map_err(|p| DbErr::Custom(format!(\"string decode panic: {p:?}\")))?;","preventionTips":["Cast to ::text in SQL when a column type may have drifted.","Re-check information_schema after ALTER TABLE migrations.","Watch for custom text domains (citext etc.) that sqlx may reject as String.","Keep sea-orm/sqlx versions consistent.","Never mix bytea data into columns labeled text in the proxy metadata."],"tags":["postgres","sqlx","type-mismatch","string","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"}