prisma: PANIC: called `Option::unwrap()` on a `None` value in query-engine\core\src\query_document\parser.rs:250:87
Hi Prisma Team! My Prisma Client crashes when using an ridiculous large number for an field of type Integer. In this case, fixing my business logic will be fairly simple, what does make me feel uncomfortabl is, that all further calls on the prisma client (singleton, as described here) will give me a similar error as stated below. I now manually need to create a new instance of my PrismaClient or better, restart the whole application. I am pretty sure, that those invalid inputs weren’t crashing my whole PrismaClient a few weeks ago. What happend?
Update: Change query data to indicate integer input is actually formated in scientific notation
This is the report:
Versions
Name | Version |
---|---|
Node | v14.16.0 |
OS | windows |
Prisma Client | 3.6.0 |
Query Engine | 0.1.0 |
Database | postgresql |
Logs
:client:libraryEngine library started
prisma:client:libraryEngine library started
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:client:libraryEngine library started
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:tryLoadEnv Environment variables loaded from C:\code\project\app\.env
prisma:client clientVersion: 3.6.0
prisma:client clientEngineType: library
prisma:client:libraryEngine internalSetup
prisma:client:libraryEngine Search for Query Engine Library in C:\code\project\app\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using C:\code\project\app\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine sending request, this.libraryStarted: false
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
Client Snippet
public async save(entity: Entity): Promise<Entity> {
const insertQuery = {
data: entity
};
try {
return await this.db.client.entity.create(insertQuery); // this.db.client retrieves a singleton of the PrismaClient
} catch (e) {
console.error(e);
throw new ApiError(`Error on Save`, e);
}
}
Schema
model entity {
id Int @id @default(autoincrement())
....
intField Int
...
someRelation Relation @relation(fields: [someRelationId], references: [id], onDelete: Cascade)
}
Prisma Engine Query (Initial query that will crash the PrismaClient)
{"data": { ..., intField: 1.1111111111111111e+61,, ... }}
Stderr on query that will crash the client
thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', query-engine\core\src\query_document\parser.rs:250:87
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PrismaClientUnknownRequestError:
Invalid `this.db.client.entity.create()` invocation in
C:\code\project\app\domain\entity\entity.dao.js:93:77
90 _a.label = 1;
91 case 1:
92 _a.trys.push([1, 3, , 4]);
 93 return [4 /*yield*/, this.db.client.entity.create(insertQuery)];
called `Option::unwrap()` on a `None` value
at Object.request (C:\code\project\app\node_modules\@prisma\client\runtime\index.js:39049:15) {
clientVersion: '3.6.0'
}
Stderr on any subsequent query
PrismaClientRustPanicError:
Invalid `this.db.client.COMPLETLY_DIFFERENT_ENTITY.findUnique()` invocation in
C:\code\project\app\domain\projekt\projekt.dao.js:112:69
109 _a.label = 1;
110 case 1:
111 _a.trys.push([1, 3, , 4]);
 112 return [4 /*yield*/, this.db.client.projekt.findUnique(findByIdQuery)];
PANIC: called `Option::unwrap()` on a `None` value in query-engine\core\src\query_document\parser.rs:250:87
This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
... <link stuff>
If you want the Prisma team to look into it, please open the link above ƒÖÅ
To increase the chance of success, please post your schema and a snippet of
how you used Prisma Client in the issue.
at Object.request (C:\code\project\app\node_modules\@prisma\client\runtime\index.js:39053:15) {
clientVersion: '3.6.0'
}
Error: Error on Save ...
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 15 (4 by maintainers)
3.15 will ship a change that returns a structured error instead of a panic.
@kasir-barati, since this is a extremly serious issue we assessed that we add a manual strict validation on all affected fields.
Thanks for the awesome reproduction @dguenther - couldn’t be easier than that one.
While playing with that (trying to understand why this does not behave as expected besides the Engine side crash) I discovered a small regression in our error logic: https://github.com/prisma/prisma/issues/11362 Usually the message about the non recoverable error should definitely already be shown on the first query - not only on the second one.
I’m reposting my comment here because I think this issue is actually pretty urgent and there is a clear reproduction case provided by @dguenther .
https://github.com/prisma/prisma-engines/pull/2589
I’ve also seen this issue. I created a simple reproduction case to help with debugging here: https://github.com/dguenther/prisma-panic-demo