drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
22.99k stars 550 forks source link

[BUG]: Error when running npx drizzle-kit introspect: "Expected object, received string" #2657

Closed 1mono2 closed 2 weeks ago

1mono2 commented 1 month ago

What version of drizzle-orm are you using?

0.32.0

What version of drizzle-kit are you using?

0.23.0

Describe the Bug

When attempting to run the command npx drizzle-kit introspect with drizzle-kit version 0.23.0 and drizzle-orm version 0.32.0, I encounter the following error:

drizzle-kit: v0.23.0
drizzle-orm: v0.32.0

No config path provided, using default path
Reading config file '/usr/src/app/drizzle.config.ts'
/usr/src/app/node_modules/drizzle-kit/bin.cjs:5186
            const error2 = new ZodError(ctx.common.issues);
                           ^

_ZodError: [
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [
      "database"
    ],
    "message": "Expected object, received string"
  }
]
    at Object.get error [as error] (/usr/src/app/node_modules/drizzle-kit/bin.cjs:5186:28)
    at _ZodObject.parse (/usr/src/app/node_modules/drizzle-kit/bin.cjs:5266:22)
    at preparePullConfig (/usr/src/app/node_modules/drizzle-kit/bin.cjs:20462:33)
    at async _Command.<anonymous> (/usr/src/app/node_modules/drizzle-kit/bin.cjs:131691:7) {
  issues: [
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'string',
      path: [ 'database' ],
      message: 'Expected object, received string'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)],
  errors: [
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'string',
      path: [ 'database' ],
      message: 'Expected object, received string'
    }
  ]
}

Configuration:

I have placed the drizzle.config.ts file in the project root with the following content:

import { defineConfig } from 'drizzle-kit';
import * as dotenv from "dotenv";

dotenv.config();

export default defineConfig({
  dialect: 'postgresql',
  out: './drizzle',
  schema: './drizzle/schema.ts',
  dbCredentials: {
    host: process.env.DB_HOST!,
    port: Number(process.env.DB_PORT!),
    user: process.env.DB_USER!,
    password: process.env.DB_PASSWORD!,
    database: process.env.DB_NAME!
  },
  verbose: true,
  strict: true,
});

Steps to Reproduce:

Place the drizzle.config.ts file in the project root with the content provided above. Run the command npx drizzle-kit introspect.

What I have tried:

Changing the dbCredentials values. Downgrading drizzle-kit to 0.22.8 and drizzle-orm to 0.31.4, which resolved the issue.

Thank you for looking into this issue. If you need any further information, please let me know.

Expected behavior

The command npx drizzle-kit introspect should execute successfully without errors.

Environment & setup

Docker environment using node:16 image Host machine: M1 MacBook running macOS Sonoma 14.0

hatemjaber commented 1 month ago

Just to piggy back on the same issue... I downgraded only the drizzle-kit to 0.22.8 and it seems to work.

lagnat commented 1 month ago

Just to piggy back on the piggy back.. same results here.

rogerhlg commented 1 month ago

same here

tommyfok commented 1 month ago

一9样,睇来系bug

AndriiSherman commented 2 weeks ago

This should be fixed in drizzle-kit@0.24.1 If you still encounter this issue, please reopen the ticket