drizzle-orm: [BUG]: Cannot destructure property 'resourceArn' of 'connection' as it is undefined

What version of drizzle-orm are you using?

?

What version of drizzle-kit are you using?

?

Describe the Bug

From drizzle-kit-mirror repo.

https://github.com/drizzle-team/drizzle-kit-mirror/issues/605

Hello,

When trying to run the studio, with AWS data-api postgres, i’m getting the following

Error:

TypeError: Cannot destructure property ‘resourceArn’ of ‘connection’ as it is undefined.

I think the bug has been introduced in this commit, drizzle-team/drizzle-orm@6f4fc4c#diff-b89d8d3caa6777e0a8c2194727aa2978387676f9b659726d5f91d5e365dd655fR124

aws-data-api/pg driver.ts

Connection param seems to come from the new API of drizzle, maybe it has not been propagated to drizzle.config.ts for the data-api ?

Thanks

https://github.com/drizzle-team/drizzle-kit-mirror/issues/606

wisedan@ML-N96CF5J61F bestrev_backend % npx drizzle-kit migrate
No config path provided, using default 'drizzle.config.ts'
Reading config file '/Users/wisedan/bestrev/bestrev_backend/drizzle.config.ts'
db name -----
resourceArn arn:aws:rds:-----------
secretArn arn:aws:secretsmanager:---------
**TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined.**
    at drizzle (/Users/wisedan/bestrev/bestrev_backend/node_modules/src/aws-data-api/pg/driver.ts:171:10)
    at preparePostgresDB (/Users/wisedan/bestrev/bestrev_backend/node_modules/drizzle-kit/bin.cjs:64043:22)
    at async Object.handler (/Users/wisedan/bestrev/bestrev_backend/node_modules/drizzle-kit/bin.cjs:87123:39)
    at async run (/Users/wisedan/bestrev/bestrev_backend/node_modules/drizzle-kit/bin.cjs:85613:7)

drizzle.config.ts

import 'dotenv/config';

import { defineConfig } from 'drizzle-kit';

console.log(process.env.RDS_DB_NAME);
console.log(process.env.RDS_DB_CLUSTER_ARN);
console.log(process.env.RDS_DB_SECRET_ARN);

export default defineConfig({
  dialect: 'postgresql',
  dbCredentials: {
    // url: process.env.DATABASE_URL || 'no-database-url-set',
    database: process.env.RDS_DB_NAME || 'no-database-name-set',
    resourceArn: 'no-cluster-arn-set',
    secretArn: process.env.RDS_DB_SECRET_ARN || 'no-secret-set',
  },
  driver: 'aws-data-api',
  schema: './packages/core/src/drizzle/schema',
  out: './packages/core/src/drizzle/migrations',
  introspect: {
    casing: 'camel',
  },
});

package versions:

 ├── @aws-sdk/client-rds-data@3.677.0
│ ├── @faker-js/faker@8.4.1
│ ├── @types/lodash@4.14.202
│ ├── @types/node@20.11.24
│ ├── @types/pg@8.11.10 deduped
│ ├── dayjs@1.11.10
│ ├── drizzle-kit@0.26.2
│ ├── drizzle-orm@0.35.3
│ ├── graphql-tag@2.12.6
│ ├── jsdom@24.1.0
│ ├── lodash@4.17.21 deduped
│ ├── pg@8.13.0
│ ├── sst@2.41.4 deduped
│ └── vitest@1.6.0

Let me know if there is anything else helpful I could provide, and thank you for your time.

Expected behavior

No response

Environment & setup

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 17
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

should be fixed in drizzle-orm@0.41.0

We are also having this issue with the latest as of today.

Bumping this hoping for a resolution!

Hello, the following patch file fixes the issue for me: https://gist.github.com/NikolaRusakov/88858b5b6a4e1585ca772f40f4e4d559#file-drizzle-orm-0-36-1-patch

the first if branch won’t evaluate instanceof expression. I had to use constructor.name workaround, use it with caution.

https://github.com/NikolaRusakov/drizzle-orm/blob/94dd9a211137b571d5575c5171754c0c908b8195/drizzle-orm/src/aws-data-api/pg/driver.ts#L152-162

This is still an issue with "drizzle-orm": "^0.36.4" and "drizzle-kit": "^0.28.1". Thank you very much for the patch @NikolaRusakov.

Is anyone working on an upstream fix here?

Any update on this? I haven’t had any luck with drizzle studio when using data api