{"record":{"id":"130f4edd80c828e5","repo":"SeaQL/sea-orm","slug":"failed-to-get-uuid-130f4e","errorCode":null,"errorMessage":"Failed to get uuid","messagePattern":"Failed to get uuid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":928,"sourceCode":"                            feature = \"postgres-array\"\n                        ))]\n                        \"TIMETZ[]\" => Value::Array(\n                            sea_query::ArrayType::TimeTime,\n                            row.try_get::<Option<Vec<time::Time>>, _>(c.ordinal())\n                                .expect(\"Failed to get timetz array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::TimeTime(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-uuid\")]\n                        \"UUID\" => Value::Uuid(\n                            row.try_get::<Option<uuid::Uuid>, _>(c.ordinal())\n                                .expect(\"Failed to get uuid\"),\n                        ),\n\n                        #[cfg(all(feature = \"with-uuid\", feature = \"postgres-array\"))]\n                        \"UUID[]\" => Value::Array(\n                            sea_query::ArrayType::Uuid,\n                            row.try_get::<Option<Vec<uuid::Uuid>>, _>(c.ordinal())\n                                .expect(\"Failed to get uuid array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Uuid(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        _ => unreachable!(\"Unknown column type: {}\", c.type_info().name()),\n                    },","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L910-L946","documentation":"ProxyRow panics with this message when sqlx's `row.try_get::<Option<uuid::Uuid>, _>` fails while converting a Postgres UUID column into Value::Uuid. try_get errors when the column is not actually a uuid type (e.g. varchar/text storing UUID strings, or bytea) or the raw value is not 16 bytes. The expect() turns this into a panic instead of a Result error.","triggerScenarios":"Selecting a column declared TEXT/VARCHAR (or bytea) that the entity treats as UUID; casting results incorrectly; a custom id generator storing non-uuid data in a uuid column; using `RETURNING` with expressions that change the type.","commonSituations":"Legacy schemas storing UUIDs as text; migrations where id columns were recreated with the wrong type; ORMs/libs mismatched where column type changed from uuid to text; raw SQL expressions like `id::text` returned but expected uuid.","solutions":["Check the column type; if it's text/varchar, either change it to uuid (`ALTER TABLE t ALTER COLUMN id TYPE uuid USING id::uuid`) or change the entity field to String.","Regenerate entities with sea-orm-cli after schema changes.","Cast in the query so the driver receives uuid: `SELECT id::uuid FROM ...`.","If the value is genuinely not a valid UUID (e.g. '0000'), fix the data — sqlx cannot decode invalid UUID bytes.","Enable the with-uuid feature on sea-orm/sea-query/sqlx consistently."],"exampleFix":"// before: id stored as text -> panic \"Failed to get uuid\"\n// after: migrate column to real uuid type\n-- ALTER TABLE users ALTER COLUMN id TYPE uuid USING id::uuid;","handlingStrategy":"validation","validationCode":"let t = sqlx::query(\n    \"SELECT data_type FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\"\n).bind(\"users\").bind(\"id\")\n .fetch_one(db).await?;\nassert_eq!(t.get::<String,_>(\"data_type\"), \"uuid\");","typeGuard":"fn as_uuid(v: &str) -> Option<uuid::Uuid> {\n    uuid::Uuid::parse_str(v).ok()\n}","tryCatchPattern":"let row = std::panic::catch_unwind(|| {\n    // conversion reading the uuid column\n});\nmatch row {\n    Ok(r) => Ok(r),\n    Err(_) => Err(DbErr::Custom(\"uuid column decode failed\".into())),\n}","preventionTips":["Never store UUIDs in text/varchar columns if entities map them as Uuid.","Validate UUID strings with Uuid::parse_str before inserting into text columns.","Keep the with-uuid feature enabled across sea-orm/sea-query/sqlx.","Regenerate entities when column types change."],"tags":["postgres","sqlx","uuid","type-mismatch","decode"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}