Skip to content

Passing null to a string some filter crashes the engine #5067

@harri121

Description

@harri121

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v12.18.3
OS debian-openssl-1.1.x
Prisma 2.4.1

Logs

2020-08-16T09:31:54.778Z prisma-client {
  engineConfig: {
    cwd: '/usr/src/app',
    enableDebugLogs: false,
    enableEngineDebugMode: undefined,
    datamodelPath: '/usr/src/app/node_modules/.prisma/client/schema.prisma',
    prismaPath: undefined,
    engineEndpoint: undefined,
    generator: {
      name: 'client',
      provider: 'prisma-client-js',
      output: '/usr/src/app/node_modules/@prisma/client',
      binaryTargets: [],
      previewFeatures: [Array],
      config: {}
    },
    showColors: false,
    logLevel: undefined,
    logQueries: undefined,
    flags: [],
    clientVersion: '2.4.1',
    enableExperimental: [ 'aggregations' ]
  }
}
2020-08-16T09:31:55.139Z plusX Execution permissions of /usr/src/app/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine
2020-08-16T09:31:55.162Z prisma-client Client Version 2.4.1
2020-08-16T09:31:55.162Z prisma-client Engine Version 195d4bdc2d16132977f4ba7a8ca312f7906cb086
2020-08-16T09:32:00.929Z prisma-client Error: PANIC: index out of bounds: the len is 1 but the index is 1

This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.

https://github.com/prisma/prisma-client-js/issues/new?body=Hi+Prisma+Team%21+My+Prisma+Client+just+crashed.+This+is+the+report%3A%0A%23%23+Versions%0A%0A%7C+Name+++++%7C+Version++++++++++++%7C%0A%7C----------%7C--------------------%7C%0A%7C+Node+++++%7C+v12.18.3+++++++++++%7C+%0A%7C+OS+++++++%7C+debian-openssl-1.1.x%7C%0A%7C+Prisma+++%7C+2.4.1++++++++++++++%7C%0A%0A%0A%0A%23%23+Logs%0A%60%60%60%0A2020-08-16T09%3A31%3A54.778Z+prisma-client+%7B%0A++engineConfig%3A+%7B%0A++++cwd%3A+%27%2Fusr%2Fsrc%2Fapp%27%2C%0A++++enableDebugLogs%3A+false%2C%0A++++enableEngineDebugMode%3A+undefined%2C%0A++++datamodelPath%3A+%27%2Fusr%2Fsrc%2Fapp%2Fnode_modules%2F.prisma%2Fclient%2Fschema.prisma%27%2C%0A++++prismaPath%3A+undefined%2C%0A++++engineEndpoint%3A+undefined%2C%0A++++generator%3A+%7B%0A++++++name%3A+%27client%27%2C%0A++++++provider%3A+%27prisma-client-js%27%2C%0A++++++output%3A+%27%2Fusr%2Fsrc%2Fapp%2Fnode_modules%2F%40prisma%2Fclient%27%2C%0A++++++binaryTargets%3A+%5B%5D%2C%0A++++++previewFeatures%3A+%5BArray%5D%2C%0A++++++config%3A+%7B%7D%0A++++%7D%2C%0A++++showColors%3A+false%2C%0A++++logLevel%3A+undefined%2C%0A++++logQueries%3A+undefined%2C%0A++++flags%3A+%5B%5D%2C%0A++++clientVersion%3A+%272.4.1%27%2C%0A++++enableExperimental%3A+%5B+%27aggregations%27+%5D%0A++%7D%0A%7D%0A2020-08-16T09%3A31%3A55.139Z+plusX+Execution+permissions+of+%2Fusr%2Fsrc%2Fapp%2Fnode_modules%2F.prisma%2Fclient%2Fquery-engine-debian-openssl-1.1.x+are+fine%0A2020-08-16T09%3A31%3A55.162Z+prisma-client+Client+Version+2.4.1%0A2020-08-16T09%3A31%3A55.162Z+prisma-client+Engine+Version+195d4bdc2d16132977f4ba7a8ca312f7906cb086%0A%60%60%60&title=PANIC%3A+index+out+of+bounds%3A+the+len+is+1+but+the+index+is+1&template=bug_report.md

If you want the Prisma team to look into it, please open the link above 🙏

    at NodeEngine.handleRequestError (/usr/src/app/node_modules/@prisma/client/runtime/index.js:1:115267)
    at /usr/src/app/node_modules/@prisma/client/runtime/index.js:1:129724
    at async PrismaClientFetcher.request (/usr/src/app/node_modules/@prisma/client/runtime/index.js:1:210694)
    [...]
2020-08-16T09:32:00.935Z plusX Execution permissions of /usr/src/app/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine
2020-08-16T09:32:05.105Z plusX Execution permissions of /usr/src/app/node_modules/.prisma/client/query-engine-debian-openssl-1.1.x are fine

Reproduction

Schema

model User {
  id  String  @default(cuid()) @id
  posts  Posts[]?  @relation("UserToPosts")
}

model Post {
  id  String  @default(cuid()) @id
  author  User  @relation("UserToPosts", fields: [authorId], references: [id])    
  authorId  String     
  someField SomeModel? 
}

model SomeModel {  id  String  @default(cuid()) @id
  post Post  @relation(fields: [postId], references: [id])   
  postId String
}

Query

Prisma.client.user.findMany({
  where: {
    posts: {
      some: {
       someField: null
      }
    }
 })

The generated client suggests that this query is valid. It nevertheless crashes with the error log from above.

Fix
To fix this issue the foreign key for SomeModel has to be stored in the Post model instead of the SomeModel model.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions