{"id":"4c387d15d2a3d76c","repo":"drizzle-team/drizzle-orm","slug":"unknown-type-for-value","errorCode":null,"errorMessage":"Unknown type for ${value}","messagePattern":"Unknown type for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-orm/src/aws-data-api/common/index.ts","lineNumber":93,"sourceCode":"\t\t\t\tresponse.value = { stringValue: value.replace('T', ' ').replace('Z', '') };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tresponse.value = { stringValue: value };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (typeof value === 'number' && Number.isInteger(value)) {\n\t\tresponse.value = { longValue: value };\n\t} else if (typeof value === 'number' && !Number.isInteger(value)) {\n\t\tresponse.value = { doubleValue: value };\n\t} else if (typeof value === 'boolean') {\n\t\tresponse.value = { booleanValue: value };\n\t} else if (value instanceof Date) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t// TODO: check if this clause is needed? Seems like date value always comes as string\n\t\tresponse.value = { stringValue: value.toISOString().replace('T', ' ').replace('Z', '') };\n\t} else {\n\t\tthrow new Error(`Unknown type for ${value}`);\n\t}\n\n\treturn response;\n}\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/aws-data-api/common/index.ts#L75-L98","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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`.","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."],"exampleFix":"// before\nawait db.insert(table).values({ data: myObject });\n// after\nawait db.insert(table).values({ data: JSON.stringify(myObject) });","handlingStrategy":"validation","validationCode":"// Validate bind values before sending to the Data API driver\nfunction assertBindable(v: unknown) {\n  const ok = v === null || typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v instanceof Date;\n  if (!ok) throw new Error(`Unsupported bind value type: ${typeof v}`);\n}","typeGuard":"function isDataApiBindable(v: unknown): v is null | string | number | boolean | Date {\n  return v === null || ['string', 'number', 'boolean'].includes(typeof v) || v instanceof Date;\n}","tryCatchPattern":"try {\n  await db.insert(table).values(row);\n} catch (e) {\n  if ((e as Error).message.startsWith('Unknown type for')) {\n    // stringify objects/BigInt/date-wrappers before retrying\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["drizzle-orm","aws-data-api","params","serialization"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}