called `Option::unwrap()` on a `None` value
See original GitHub issueHello, I’ve started getting this Prisma Client error in my test environment without any changes to Prisma/query code. This is the report:
Versions
Name | Version |
---|---|
Node | v16.15.1 |
OS | windows |
Prisma Client | 4.1.0 |
Query Engine | 8d8414deb360336e4698a65aa45a1fbaf1ce13d8 |
Database | sqlite |
Logs
thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', query-engine\core\src\response_ir\internal.rs:543:81
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error:
Invalid `prisma.users.findMany()` invocation:
called `Option::unwrap()` on a `None` value
This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
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 RequestHandler.handleRequestError (<project_path>\node_modules\@prisma\client\runtime\index.js:28666:13)
at RequestHandler.request (<project_path>\node_modules\@prisma\client\runtime\index.js:28640:12)
at async consumer (<project_path>\node_modules\@prisma\client\runtime\index.js:29618:18)
at async PrismaClient._request (<project_path>\node_modules\@prisma\client\runtime\index.js:29639:16)
at async GET (<project_path>\src\routes\api\players.js:6:19)
at async render_endpoint (file:///<project_path>/.svelte-kit/runtime/server/index.js:260:19)
at async resolve (file:///<project_path>/.svelte-kit/runtime/server/index.js:3452:11)
at async respond (file:///<project_path>/.svelte-kit/runtime/server/index.js:3389:20)
at async fetch (file:///<project_path>/.svelte-kit/runtime/server/index.js:2437:17)
at async load (leaderboard.svelte:5:15)
Unexpected token < in JSON at position 0
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Proxy.<anonymous> (file:///<project_path>/.svelte-kit/runtime/server/index.js:2556:21)
at async load (leaderboard.svelte:6:21)
at async load_node (file:///<project_path>/.svelte-kit/runtime/server/index.js:2582:22)
at async respond$1 (file:///<project_path>/.svelte-kit/runtime/server/index.js:2983:15)
at async resolve (file:///<project_path>/.svelte-kit/runtime/server/index.js:3453:11)
at async respond (file:///<project_path>/.svelte-kit/runtime/server/index.js:3389:20)
at async file:///<project_path>/node_modules/@sveltejs/kit/dist/vite.js:2382:22
Client Snippet
The code below is of a SvelteKit endpoint.
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
export async function GET() {
var players = await prisma.users.findMany({
orderBy: {
stats: {ranking: 'desc'}
},
include: {
stats: {
select: {
ranking: true,
law_victories: true,
crim_victories: true,
law_defeats: true,
crim_defeats: true,
law_time: true,
crim_time: true,
}
},
friends: false
}
});
return {
status: 200,
body: players,
}
}
Schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
// 'users' SQLite model
model users {
id Int @id @unique
pid Int @unique
username String @unique
country String?
birthday_date Int?
clan_tag String?
stats stats?
friends friends[]
}
// 'friends' SQLite model
model friends {
id Int @id @unique
user users @relation(fields: [friend_of], references: [pid])
friend_of Int
pid Int
name String
details Int
clan_abbr String
wanna_play Int
}
// 'message' SQLite model
model message {
msg String @unique
}
// 'stats' SQLite model
model stats {
id Int @id @unique
user users @relation(fields: [pid], references: [pid])
pid Int @unique
ranking Int?
law_victories Int?
law_defeats Int?
law_draws Int?
crim_victories Int?
crim_defeats Int?
crim_draws Int?
law_kills Int?
crim_kills Int?
law_deaths Int?
crim_deaths Int?
law_suicides Int?
crim_suicides Int?
law_headshots Int?
crim_headshots Int?
stat16 Int?
stat17 Int?
stat18 Int?
stat19 Int?
law_hostages_killed Int?
crim_hostages_killed Int?
law_apprehensions Int?
crim_apprehended Int?
law_shots_fired Int?
crim_shots_fired Int?
law_shots_hit Int?
crim_shots_hit Int?
law_time Int?
crim_time Int?
}
Prisma Engine Query
{"X":{}}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Panicked at 'called `Option::unwrap()` on a `None` value ...
Hi! I'm currently porting the Lox language from Crafting Interpreters , but I've been stuck for a while in an annoying bug.
Read more >thread 'rustc' panicked at 'called `Option::unwrap()` on a `None ...
A-incr-comp Area: Incremental compilation C-bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler.
Read more >Called `Option::unwrap()` on a `None` value - Editors and IDEs
I get this macro expansion warning with matklad.rust-analyzer v 0.2.776 with VSCode but not with cargo builld.
Read more >stylo: panicked at 'called `Option::unwrap()` on a `None` value'
The attached testcase causes a panic in m-c rev 68046a58f829 thread 'StyleThread#1' panicked at 'called `Option::unwrap()` on a `None` value', ...
Read more >libpnet error: thread 'main' panicked at 'called `Option::unwrap ...
It seems that adding tcp_header.set_options() results in a panic. thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, thank you for actually letting us know. Although this is invalid data, we should probably try to fail in a better way with a more helpful error message I would say.
I assume because this is SQLite it let you write whatever into the
Int
field instead?Yes, thanks for drawing my attention to that, I’ve just solved it. I’ve got new
user
records with errorousbirthday_date
SQLite field values (saved in scientific notation, e.g.1.84467440724388e+19
, just a parsing bug), which was the root cause for this. After a correction everything is back to normal. Thanks for help and sorry for trouble, i forgot to check the data.