SeaQL/sea-orm · error

Failed to get uuid array

Error message

Failed to get uuid array

What it means

Panic raised when sea-orm-sync's PostgreSQL driver fails to decode a "UUID[]" array column into Option<Vec<uuid::Uuid>> while building a ProxyRow. Like the scalar case, .expect() turns any sqlx decode failure into an unrecoverable panic.

Source

Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:922

                                    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)

Solutions

  1. Inspect the array contents (SELECT unnest(col)::text) to find undecodable or NULL elements
  2. Ensure the column is a genuine uuid[] and elements are valid uuids, or change the match arm to match the real type_info name
  3. Verify the with-uuid and postgres-array features are both enabled and crate versions are compatible
  4. Propagate the sqlx error instead of .expect and skip/coerce undecodable elements

Example fix

// before
"UUID[]" => Value::Array(
    sea_query::ArrayType::Uuid,
    row.try_get::<Option<Vec<uuid::Uuid>>, _>(c.ordinal())
        .expect("Failed to get uuid array")
        .map(|vals| ...),
),
// after
"UUID[]" => Value::Array(
    sea_query::ArrayType::Uuid,
    row.try_get::<Option<Vec<uuid::Uuid>>, _>(c.ordinal())
        .unwrap_or_else(|e| panic!("Failed to get uuid array for col {}: {}", c.name(), e))
        .map(|vals| ...),
),
Defensive patterns

Strategy: validation

Validate before calling

// Verify array elements are decodable uuids:
// SELECT unnest(col)::text FROM t WHERE NOT (col::text ~ '^{...}$');

Type guard

fn is_uuid_array(type_name: &str) -> bool { type_name == "UUID[]" }

Try / catch

let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());

Prevention

When it happens

Trigger: Reading a Postgres uuid[] column with the postgres-array and with-uuid features enabled when an element cannot be decoded to uuid::Uuid — e.g. NULL elements, array stored as text, or type metadata reporting UUID[] for a non-uuid array.

Common situations: Arrays written by raw SQL with mixed/NULL elements; schema drift after ALTER COLUMN type; feature flag (postgres-array) enabled but array elements stored in a non-standard representation by another ORM version.

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/92bd0ad839026e2c. Report an issue: GitHub.