SeaQL/sea-orm · error

Failed to get uuid array

Error message

Failed to get uuid array

What it means

ProxyRow panics with this message when sqlx's `row.try_get::<Option<Vec<uuid::Uuid>>, _>` fails while converting a Postgres UUID[] column into Value::Array(Uuid). try_get errors when the column is not a uuid[] array (scalar uuid, uuid[] stored as text[], nested arrays) or an element cannot be decoded as a 16-byte UUID. The expect() panics on the underlying sqlx error.

Solutions

  1. Verify the column type is `uuid[]` (element type uuid) in information_schema.columns.
  2. Cast in SQL when the source is text[]: `SELECT tags::uuid[] FROM ...`.
  3. Use `array_agg(id::uuid)` so the aggregate element type is uuid.
  4. Regenerate entities so the field type is Vec<Uuid> matching uuid[].
  5. Unnest multi-dimensional arrays or reshape them in SQL to a 1-D uuid[].

Example fix

// before: array_agg returns text[] -> panic "Failed to get uuid array"
// SELECT array_agg(tag_id) FROM post_tags

// after
// SELECT array_agg(tag_id::uuid) AS tag_ids FROM post_tags
Defensive patterns

Strategy: validation

Validate before calling

let t = sqlx::query(
    "SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2"
).bind("posts").bind("tag_ids")
 .fetch_one(db).await?;
assert_eq!(t.get::<String,_>("udt_name"), "_uuid");

Type guard

fn as_uuid_vec(vals: &[String]) -> Option<Vec<uuid::Uuid>> {
    vals.iter().map(|s| uuid::Uuid::parse_str(s).ok()).collect()
}

Try / catch

let out = std::panic::catch_unwind(|| {
    // conversion reading the uuid[] column
});
if out.is_err() {
    return Err(DbErr::Custom("uuid[] column decode failed".into()));
}

Prevention

When it happens

Trigger: A column expected as UUID[] is actually scalar uuid, `text[]`, or a multi-dimensional array; aggregate expressions (e.g. array_agg over text) return non-uuid arrays; postgres-array feature toggles differ from what the value requires.

Common situations: array_agg(id) over a text-typed column; columns migrated from text[] to uuid[] without entity update; schemas where tag/permission arrays were stored as text arrays; feature flags missing postgres-array so the value shape differs.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10). Data as JSON: /api/errors/2d66907d27b2dab9. Report an issue: GitHub.

Appendix: source

Thrown at src/driver/sqlx_postgres.rs:935

                                    Box::new(
                                        vals.into_iter()
                                            .map(|val| Value::TimeTime(Some(val)))
                                            .collect(),
                                    )
                                }),
                        ),

                        #[cfg(feature = "with-uuid")]
                        "UUID" => Value::Uuid(
                            row.try_get::<Option<uuid::Uuid>, _>(c.ordinal())
                                .expect("Failed to get uuid"),
                        ),

                        #[cfg(all(feature = "with-uuid", feature = "postgres-array"))]
                        "UUID[]" => Value::Array(
                            sea_query::ArrayType::Uuid,
                            row.try_get::<Option<Vec<uuid::Uuid>>, _>(c.ordinal())
                                .expect("Failed to get uuid array")
                                .map(|vals| {
                                    Box::new(
                                        vals.into_iter()
                                            .map(|val| Value::Uuid(Some(val)))
                                            .collect(),
                                    )
                                }),
                        ),

                        _ => unreachable!("Unknown column type: {}", c.type_info().name()),
                    },
                )
            })
            .collect(),
    }
}

View on GitHub (pinned to e29bcd1b41)