Skip to content

Panic on a table that only has an ID, "called Option::unwrap() on a None value" #1793

@divyenduz

Description

@divyenduz

This can be seen on this table in mysql/sportsdb database

CREATE TABLE `baseball_defensive_group` (
  `id` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

To reproduce, import the SQL of this table locally into a MySQL database and introspect it (prisma2 introspect --url <db-connection-string>). Then run the following client call:

const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

async function main() {
  const data = await prisma.baseball_defensive_group.create()
  console.log(data)
}

main()

It yields the error:

PANIC: called `Option::unwrap()` on a `None` value
    at PrismaClientFetcher.request (/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/runtime/index.js:1:47203)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:43197) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Full error with DEBUG flag:

divyendusingh [p2-no-data]$ node index.js 
  prisma-client {
  prisma-client   engineConfig: {
  prisma-client     cwd: '/Users/divyendusingh/Documents/prisma/p2-no-data',
  prisma-client     debug: false,
  prisma-client     datamodelPath: '/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/clie
nt/schema.prisma',
  prisma-client     prismaPath: undefined,
  prisma-client     datasources: [],
  prisma-client     generator: {
  prisma-client       name: 'client',
  prisma-client       provider: 'prisma-client-js',
  prisma-client       output: '/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client',
  prisma-client       binaryTargets: [],
  prisma-client       config: {}
  prisma-client     },
  prisma-client     showColors: true,
  prisma-client     logLevel: undefined,
  prisma-client     logQueries: undefined,
  prisma-client     env: {},
  prisma-client     flags: []
  prisma-client   }
  prisma-client } +0ms
  prisma-client Prisma Client call: +9ms
  prisma-client prisma.baseball_defensive_group.create(undefined) +0ms
  prisma-client Generated request: +0ms
  prisma-client mutation {
  prisma-client   createOnebaseball_defensive_group {
  prisma-client     id
  prisma-client   }
  prisma-client }
  prisma-client  +0ms
  getos { platform: 'darwin', libssl: undefined } +0ms
  engine {
  engine   PRISMA_DML_PATH: '/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/schema.prisma',
  engine   PORT: '49716',
  engine   RUST_BACKTRACE: '1',
  engine   RUST_LOG: 'info',
  engine   OVERWRITE_DATASOURCES: '[]',
  engine   CLICOLOR_FORCE: '1'
  engine } +0ms
  engine { cwd: '/Users/divyendusingh/Documents/prisma/p2-no-data' } +0ms
  plusX Execution permissions of /Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/runtime/query-engine-darwin are fine +0ms
  engine { flags: [ '--enable-raw-queries' ] } +1ms
  engine stderr Printing to stderr for debugging +15ms
  engine stderr Listening on 127.0.0.1:49716 +1ms
  engine stdout {
  timestamp: 'Mar 09 19:36:43.129',
  level: 'INFO',
  target: 'quaint::pooled',
  fields: { message: 'Starting a mysql pool with 13 connections.' }
} +0ms
  engine stdout {
  timestamp: 'Mar 09 19:36:43.135',
  level: 'INFO',
  target: 'prisma::server',
  fields: {
    message: 'Started http server on 127.0.0.1:49716',
    'log.target': 'prisma::server',
    'log.module_path': 'prisma::server',
    'log.file': 'query-engine/prisma/src/server.rs',
    'log.line': 95
  }
} +5ms
  engine stdout {
  timestamp: 'Mar 09 19:36:43.143',
  level: 'ERROR',
  target: 'prisma',
  fields: {
    message: 'PANIC',
    reason: 'called `Option::unwrap()` on a `None` value',
    file: '/rustc/f3e1a954d2ead4e2fc197c7da7d71e6c61bad196/src/libcore/macros/mod.rs',
    line: 15,
    column: 40
  }
} +8ms
  engine {
  engine   error: Error: socket hang up
  engine       at connResetException (internal/errors.js:559:14)
  engine       at Socket.socketOnEnd (_http_client.js:433:23)
  engine       at Socket.emit (events.js:208:15)
  engine       at endReadableNT (_stream_readable.js:1168:12)
  engine       at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  engine     code: 'ECONNRESET'
  engine   }
  engine } +3ms
  printStack callsite Error
    at Object.s [as baseball_defensive_group] (/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/runtime/index.js:1:44468)
    at Object.n.<computed> [as create] (/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/runtime/index.js:1:46094)
    at main (/Users/divyendusingh/Documents/prisma/p2-no-data/index.js:6:54)
    at Object.<anonymous> (/Users/divyendusingh/Documents/prisma/p2-no-data/index.js:10:1)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    at Module.load (internal/modules/cjs/loader.js:731:32)
    at Function.Module._load (internal/modules/cjs/loader.js:644:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
    at internal/main/run_main_module.js:17:11 +0ms
(node:43197) UnhandledPromiseRejectionWarning: Error: 
Invalid `prisma.baseball_defensive_group.create()` invocation in
/Users/divyendusingh/Documents/prisma/p2-no-data/index.js:6:54

PANIC: called `Option::unwrap()` on a `None` value
    at PrismaClientFetcher.request (/Users/divyendusingh/Documents/prisma/p2-no-data/node_modules/@prisma/client/runtime/index.js:1:47203)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:43197) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:43197) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error in Prisma Client:
PANIC: called `Option::unwrap()` on a `None` value in
/rustc/f3e1a954d2ead4e2fc197c7da7d71e6c61bad196/src/libcore/macros/mod.rs:15:40

This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.
Please create an issue in https://github.com/prisma/prisma-client-js describing the last Prisma Client query you called.

Related test-utils issue: prisma/prisma-test-utils#32


Internal notes:

Test utils database(s) affected:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions