drizzle-team/drizzle-orm · error · Error
Unknown type for ${value}
Error message
Unknown type for ${value} What it means
In `toValueParam`, while converting a JavaScript value into an RDS Data API parameter, none of the type branches matched: the value is not `null`, `string`, integer, float, `boolean`, or a `Date` instance. drizzle-orm cannot encode the value for the `ExecuteStatementCommand`.
Source
Thrown at drizzle-orm/src/aws-data-api/common/index.ts:93
response.value = { stringValue: value.replace('T', ' ').replace('Z', '') };
break;
}
default: {
response.value = { stringValue: value };
break;
}
}
} else if (typeof value === 'number' && Number.isInteger(value)) {
response.value = { longValue: value };
} else if (typeof value === 'number' && !Number.isInteger(value)) {
response.value = { doubleValue: value };
} else if (typeof value === 'boolean') {
response.value = { booleanValue: value };
} else if (value instanceof Date) { // eslint-disable-line no-instanceof/no-instanceof
// TODO: check if this clause is needed? Seems like date value always comes as string
response.value = { stringValue: value.toISOString().replace('T', ' ').replace('Z', '') };
} else {
throw new Error(`Unknown type for ${value}`);
}
return response;
}
View on GitHub (pinned to b7862528fd)
Solutions
- Serialize objects to JSON strings before binding (`JSON.stringify(obj)`).
- Convert date-library wrappers to native `Date` (`dayjs.unix().toDate()`).
- Coerce BigInts to numbers or strings as appropriate for the column type.
- Pass Buffers/typed arrays only where `blobValue` is expected; otherwise encode as base64/hex string.
Example fix
// before
await db.insert(table).values({ data: myObject });
// after
await db.insert(table).values({ data: JSON.stringify(myObject) }); Defensive patterns
Strategy: validation
Validate before calling
// Validate bind values before sending to the Data API driver
function assertBindable(v: unknown) {
const ok = v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v instanceof Date;
if (!ok) throw new Error(`Unsupported bind value type: ${typeof v}`);
} Type guard
function isDataApiBindable(v: unknown): v is null | string | number | boolean | Date {
return v === null || ['string', 'number', 'boolean'].includes(typeof v) || v instanceof Date;
} Try / catch
try {
await db.insert(table).values(row);
} catch (e) {
if ((e as Error).message.startsWith('Unknown type for')) {
// stringify objects/BigInt/date-wrappers before retrying
}
throw e;
} Prevention
- JSON.stringify objects before binding to JSON columns.
- Convert date-library wrappers to native Date; coerce BigInt to number/string.
- Validate bind values with the type guard above before queries.
When it happens
Trigger: Binding a value of an unsupported runtime type — most commonly a plain object, array, `BigInt`, `Uint8Array`, `moment`/`dayjs`/luxon wrapper, or a class instance — as a query parameter through the AWS Data API driver.
Common situations: Passing a JS object for a JSON column instead of `JSON.stringify(value)`, passing a BigInt for a bigint column, or a date-library wrapper instead of a native `Date`.
Related errors
- Unknown array type
- Unknown type
- 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/4c387d15d2a3d76c.json.
Report an issue: GitHub.