question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing data source leads to "Error: Get config index out of bounds: the len is 1 but the index is 1"

See original GitHub issue

Bug description

I’m following the guide at https://vercel.com/guides/nextjs-prisma-postgres and trying to setup prisma with postgres but after I install next auth and run npx prisma db push I’m getting the error " Error: Get config index out of bounds: the len is 1 but the index is 1"

configErro

How to reproduce

Expected behavior

My Understanding is that you are required to proceed with the db being updated without any errors

Prisma information

// schema.prisma

model Post {
  id        Int     @default(autoincrement()) @id
  title     String
  content   String?
  published Boolean @default(false)
  author    User?   @relation(fields: [authorId], references: [id])
  authorId  Int?
}

model User {
  id            Int       @default(autoincrement()) @id
  name          String?
  email         String?   @unique
  emailVerified DateTime? @map(name: "email_verified")
  image         String?
  createdAt     DateTime  @default(now()) @map(name: "created_at")
  updatedAt     DateTime  @updatedAt @map(name: "updated_at")
  posts         Post[]

  @@map(name: "users")
}

model Account {
  id                 Int       @default(autoincrement()) @id
  compoundId         String    @unique @map(name: "compound_id")
  userId             Int       @map(name: "user_id")
  providerType       String    @map(name: "provider_type")
  providerId         String    @map(name: "provider_id")
  providerAccountId  String    @map(name: "provider_account_id")
  refreshToken       String?   @map(name: "refresh_token")
  accessToken        String?   @map(name: "access_token")
  accessTokenExpires DateTime? @map(name: "access_token_expires")
  createdAt          DateTime  @default(now()) @map(name: "created_at")
  updatedAt          DateTime  @default(now()) @map(name: "updated_at")

  @@index([providerAccountId], name: "providerAccountId")
  @@index([providerId], name: "providerId")
  @@index([userId], name: "userId")

  @@map(name: "accounts")
}

model Session {
  id           Int      @default(autoincrement()) @id
  userId       Int      @map(name: "user_id")
  expires      DateTime
  sessionToken String   @unique @map(name: "session_token")
  accessToken  String   @unique @map(name: "access_token")
  createdAt    DateTime @default(now()) @map(name: "created_at")
  updatedAt    DateTime @default(now()) @map(name: "updated_at")

  @@map(name: "sessions")
}

Environment & setup

  • OS: Pop OS 20.10
  • Database: PostgreSQL
  • Node.js version: v12.19.0

Prisma Version

2.23.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Dec 1, 2021

Remaining problem tracked in https://github.com/prisma/prisma/issues/7186

1reaction
janpiocommented, May 29, 2021

I can reproduce this with prisma validate for any schema missing the datasource block, e.g. an empty schema:

C:\Users\Jan\Documents\throwaway\7343>npx prisma validate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: Get config thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', query-engine\query-engine\src\opt.rs:148:21
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Thanks for reporting this @giordifungula - this is a proper bug we should fix.

(And yes, we make the mistake with prisma.schema vs. schema.prisma all the time ourselves 😆)

Read more comments on GitHub >

github_iconTop Results From Across the Web

thread '<unnamed>' panicked at 'index out of bounds: the len ...
It looks to me like something outside of hir_def is causing the problem. Almost as if the data interned in the salsa database...
Read more >
Array index out of bounds error even though the indices are ...
But I'm getting ArrayIndexOutOfBoundsException . Index 49 out of bounds for length 10. My code: public class ...
Read more >
Python IndexError: List Index Out of Range [Easy Fix] - Finxter
One frequent bug in Python is the IndexError: list index out of range . So, what does this error message mean?
Read more >
CWE-787: Out-of-bounds Write (4.9)
Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found