drizzle-team/drizzle-orm · error · Error
Unknown array type
Error message
Unknown array type
What it means
In the AWS RDS Data API result mapper, an array-typed `Field` was returned but its `arrayValue` did not contain any of the recognized element arrays (`stringValues`, `longValues`, `doubleValues`, `booleanValues`, `arrayValues`). This is an unrecognized/nested array shape the mapper cannot decode.
Source
Thrown at drizzle-orm/src/aws-data-api/common/index.ts:36
// eslint-disable-next-line unicorn/no-negated-condition
} else if (field.arrayValue !== undefined) {
if (field.arrayValue.stringValues !== undefined) {
return field.arrayValue.stringValues;
}
if (field.arrayValue.longValues !== undefined) {
return field.arrayValue.longValues;
}
if (field.arrayValue.doubleValues !== undefined) {
return field.arrayValue.doubleValues;
}
if (field.arrayValue.booleanValues !== undefined) {
return field.arrayValue.booleanValues;
}
if (field.arrayValue.arrayValues !== undefined) {
return field.arrayValue.arrayValues;
}
throw new Error('Unknown array type');
} else {
throw new Error('Unknown type');
}
}
export function typingsToAwsTypeHint(typings?: QueryTypingsValue): TypeHint | undefined {
if (typings === 'date') {
return TypeHint.DATE;
} else if (typings === 'decimal') {
return TypeHint.DECIMAL;
} else if (typings === 'json') {
return TypeHint.JSON;
} else if (typings === 'time') {
return TypeHint.TIME;
} else if (typings === 'timestamp') {
return TypeHint.TIMESTAMP;
} else if (typings === 'uuid') {
return TypeHint.UUID;View on GitHub (pinned to b7862528fd)
Solutions
- Cast the array column to a text representation in SQL (`array_col::text`) and decode it client-side.
- Avoid selecting unsupported array element types through the Data API; fetch them via a non-array projection.
- Upgrade drizzle-orm; newer versions add element-type handling for arrays.
Example fix
// before
const rows = await db.select({ arr: table.byteaArr }).from(table);
// after - cast to text
const rows = await db.execute(sql`select bytea_arr::text from t`); Defensive patterns
Strategy: try-catch
Validate before calling
// Cast exotic array columns to text before selecting via Data API
import { sql } from 'drizzle-orm';
const safe = await db.execute(sql`select bytea_arr_col::text from t`); Type guard
import type { Field } from '@aws-sdk/client-rds-data';
function hasKnownArrayValue(f: Field): boolean {
const a = f.arrayValue;
return !!a && (!!a.stringValues || !!a.longValues || !!a.doubleValues || !!a.booleanValues || !!a.arrayValues);
} Try / catch
try {
rows = await db.select({ arr: table.col }).from(table);
} catch (e) {
if ((e as Error).message === 'Unknown array type') {
rows = await db.execute(sql`select col::text from ${table}`);
} else throw e;
} Prevention
- Cast unusual array element types to text in the query.
- Track drizzle-orm releases for expanded array support.
When it happens
Trigger: Selecting an array column whose element type the RDS Data API represents with an unsupported/unhandled `arrayValue` variant (e.g. blob arrays, null arrays, or newer array element kinds). Triggered on the `getValueFromDataApi(field)` path during result decoding.
Common situations: Querying Postgres array columns with element types like `bytea[]`, `numeric[]` where the Data API returns a non-string/long/double/boolean variant, or after an AWS SDK upgrade that changed `arrayValue` shapes.
Related errors
- Unknown type
- Unknown type for ${value}
- Unexpected state: no column metadata found for index ${index
- Unexpected state: no column name for index ${index} found in
- Transaction not supported
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /data/errors/930cef0573fe5dda.json.
Report an issue: GitHub.