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 panics when you use a colon to declare field type (field: Type syntax) #9302

Closed
mikeyhew opened this issue Sep 17, 2021 · 2 comments · Fixed by prisma/prisma-engines#2896
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: prisma format CLI: prisma format
Milestone

Comments

@mikeyhew
Copy link

This is my schema. There is a syntax error because of the colon after name and htmlTitle. However I would expect to get a syntax error message instead of a panic about unreachable code.

Here is the offending schema file:

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model Site {
  name: String
  htmlTitle: String
}

here is the panic message:

thread 'main' panicked at 'internal error: entered unreachable code: Encountered impossible declaration during formatting: [Start { rule: LEGACY_COLON, pos: Position { pos: 256 } }, End { rule: LEGACY_COLON, pos: Position { pos: 257 } }]', libs/datamodel/core/src/ast/reformat/reformatter.rs:899:18
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: datamodel::ast::reformat::reformatter::Reformatter::reformat_generic_token
   3: datamodel::ast::reformat::reformatter::Reformatter::reformat_model::{{closure}}
   4: datamodel::ast::reformat::reformatter::Reformatter::reformat_block_element_internal
   5: datamodel::ast::reformat::reformatter::Reformatter::reformat_internal
   6: datamodel::ast::reformat::reformatter::Reformatter::reformat_to
   7: prisma_fmt::format::run
   8: prisma_fmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@mikeyhew mikeyhew changed the title prisma format crashes when you use a colon to declare field type (field: Type syntax) prisma format panics when you use a colon to declare field type (field: Type syntax) Sep 17, 2021
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. topic: prisma format CLI: prisma format labels Sep 17, 2021
@janpio
Copy link
Contributor

janpio commented Sep 17, 2021

I can confirm this:

C:\Users\Jan\Documents\throwaway\next-prisma-3>npx prisma format
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error: Command failed with exit code 101: C:\Users\Jan\Documents\throwaway\next-prisma-3\node_modules\@prisma\engines\prisma-fmt-windows.exe format -i C:\Users\Jan\Documents\throwaway\next-prisma-3\prisma\schema.prisma
thread 'main' panicked at 'internal error: entered unreachable code: Encountered impossible declaration during formatting: [Start { rule: LEGACY_COLON, pos: Position { pos: 161 } }, End { rule: LEGACY_COLON, pos: Position { pos: 162 } }]', libs\datamodel\core\src\ast\reformat\reformatter.rs:899:18
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Sep 17, 2021
@janpio
Copy link
Contributor

janpio commented Sep 17, 2021

Btw, the Prisma VSCode extension uses the : (or the overall GraphQL-ness of the definition) as an indicator to show this nice error message:
image
Not super correct, but I see why it thinks this might be GraphQL.

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. domain/schema Issue in the "Schema" domain: Prisma Schema, Introspection, Migrations etc. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: prisma format CLI: prisma format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants