Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large decimals cause panick #12761

Closed
haydenbriese opened this issue Apr 11, 2022 · 4 comments · Fixed by prisma/prisma-engines#2988
Closed

Large decimals cause panick #12761

haydenbriese opened this issue Apr 11, 2022 · 4 comments · Fixed by prisma/prisma-engines#2988
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: Decimal Scalar type `Decimal` topic: rust panic
Milestone

Comments

@haydenbriese
Copy link

Bug description

Prisma crashes when trying to create large decimals, even when the field is configured for a far greater precision

thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39

How to reproduce

  1. Init db using schema
  2. Execute example create

Expected behavior

I can create a decimal with a precision of 128

Prisma information

Schema

model Example {
  id     String  @id @default(uuid())
  number Decimal  @db.Decimal(128,0)
}

Call

await this.prisma.test.create({
  data: {
    number: "1" + "0".repeat(60), // 1e60
   },
});

Environment & setup

  • OS: Mac OS 12
  • Database: PostgreSQL
  • Node.js version: 16.13.2
  • @prisma/client version: 3.12.0

Prisma Version

prisma                  : 3.12.0
@prisma/client          : 3.12.0
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash    : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio                  : 0.459.0
@garrensmith
Copy link
Contributor

@haydenbriese thanks for the report. May I close this given it is a duplicate of #7061

@garrensmith garrensmith added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: Decimal Scalar type `Decimal` topic: rust panic labels Apr 11, 2022
@haydenbriese
Copy link
Author

haydenbriese commented Apr 11, 2022

@haydenbriese thanks for the report. May I close this given it is a duplicate of #7061

Though the error messages are the same, the two bugs appear to occur under different circumstances
This bug occurs for very large Decimals.
The other occurs for relatively small Decimals when they're marked with @id.

Whether they share the same underlying cause or not both cases should be tested.
I can document this case on the other ticket if you think that would be the best place for it

@garrensmith
Copy link
Contributor

Ok that sounds good. We will triage and get to it as soon as possible. Thanks for reporting.

@Weakky
Copy link
Member

Weakky commented Jun 17, 2022

Hey,

This was fixed by prisma/quaint#379 and prisma/prisma-engines#2988, and should be available in the next release.

Closing now, thanks for reporting 🙏

@Weakky Weakky closed this as completed Jun 17, 2022
@janpio janpio added this to the 4.0.x milestone Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: Decimal Scalar type `Decimal` topic: rust panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants