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

prisma format panic due to non-UTF8 characters in comments. #15926

Closed
jkomyno opened this issue Oct 21, 2022 · 3 comments
Closed

prisma format panic due to non-UTF8 characters in comments. #15926

jkomyno opened this issue Oct 21, 2022 · 3 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: error reporting Issues created via Prisma's CLI Crash Reporting topic: prisma format CLI: prisma format

Comments

@jkomyno
Copy link
Contributor

jkomyno commented Oct 21, 2022

Command: prisma format
Version: 4.3.1
Binary Version: c875e43600dfe042452e0b868f7a48b817b9640b
Report: https://prisma-errors.netlify.app/report/14385
OS: x64 darwin 21.6.0

Rust Stacktrace:

RuntimeError: unreachable
    at __rust_start_panic (<anonymous>:wasm-function[3967]:0x1f6d33)
    at rust_panic (<anonymous>:wasm-function[3214]:0x1f35d2)
    at std::panicking::rust_panic_with_hook::h84feca33bd4bd229 (<anonymous>:wasm-function[2199]:0x1d8c3a)
    at std::panicking::begin_panic_handler::{{closure}}::hd2eacd3bb9ff1eab (<anonymous>:wasm-function[2399]:0x1e16b9)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h976699518d897fb1 (<anonymous>:wasm-function[3499]:0x1f5692)
    at rust_begin_unwind (<anonymous>:wasm-function[3068]:0x1f1976)
    at core::panicking::panic_fmt::hc171d095bc4a492d (<anonymous>:wasm-function[3083]:0x1f1ce6)
    at core::str::slice_error_fail_rt::hcb3b0ba086da6bd9 (<anonymous>:wasm-function[351]:0xfe377)
    at core::ops::function::FnOnce::call_once::ha875dc1ee2d6d5c2 (<anonymous>:wasm-function[3590]:0x1f5d14)
    at core::intrinsics::const_eval_select::h931998c74f012b97 (<anonymous>:wasm-function[3402]:0x1f4e50)
@jkomyno jkomyno added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: prisma format CLI: prisma format topic: error reporting Issues created via Prisma's CLI Crash Reporting team/schema Issue for team Schema. labels Oct 21, 2022
@jkomyno
Copy link
Contributor Author

jkomyno commented Oct 24, 2022

As it turns out:

  • viewing the schema from this error report in VSCode reveals a bunch of warnings, especially about missing @unique attributes
  • format crashes because of the comments in a non-latin alphabet. Removing the Thai comments allows us to run prisma format, which results in the following managed error:
Prisma schema loaded from prisma/schema.prisma
Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: Error validating model "QrPayment": Ambiguous relation detected. The fields `payment` and `Payment` in model `QrPayment` both refer to `Payment`. Please provide different relation names for them by adding `@relation(<name>).
  -->  schema.prisma:166
   | 
165 |   loanId          String
166 |   payment         Payment?       @relation(fields: [paymentId], references: [id])
167 |   bblVerifyLogs   BblVerifyLog[] @relation("QrPaymentBblVerifyLog")
   | 

Validation Error Count: 1
[Context: getDmmf]

Prisma CLI Version : 4.5.0

@jkomyno
Copy link
Contributor Author

jkomyno commented Oct 24, 2022

I think we should stop panicking when running prisma format targeting a Prisma schema with non-UTF8 characters.
It seems we're able to properly attach warning spans in these kind of schema, but formatting just crashes hard as of v4.5.0.

@jkomyno jkomyno added bug/2-confirmed Bug has been reproduced and confirmed. process/candidate and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Oct 24, 2022
@jkomyno jkomyno changed the title prisma format panic, probably due to non-UTF8 characters in comments. prisma format panic due to non-UTF8 characters in comments. Oct 27, 2022
@tomhoule
Copy link
Contributor

Closing this as duplicate of #14895

See the comments and the linked PR: it's not about all comments, but only the path where we have a missing @relation attribute on a forward relation field. We have a bad newline-checking function there. It's part of the logic that adds fields and attributes during reformatting. Comments with multi-byte UTF-8 other than trailing comments in this particular case where we add an @relation all work.

@tomhoule tomhoule closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: error reporting Issues created via Prisma's CLI Crash Reporting topic: prisma format CLI: prisma format
Projects
None yet
Development

No branches or pull requests

2 participants