Skip to content

CLI crash when run on empty schema.prisma #7186

Closed

Description

@janpio
  • npm init -y
  • npm install prisma@dev
  • Then:
C:\Users\Jan\Documents\throwaway\envRepro  ([email protected])
λ npx prisma db push
Prisma schema loaded from schema.prisma
Error: Get config thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', query-engine\query-engine\src\opt.rs:148:21
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

C:\Users\Jan\Documents\throwaway\envRepro  ([email protected])
λ npx prisma migrate dev
Prisma schema loaded from schema.prisma
Error: Get config thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', query-engine\query-engine\src\opt.rs:148:21
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

vs. handled error in Introspection:

C:\Users\Jan\Documents\throwaway\envRepro  ([email protected])
λ npx prisma introspect
Prisma schema loaded from schema.prisma

Introspecting based on datasource defined in schema.prisma …
Error: There is no datasource in the schema.

Activity

  1. added
    bug/1-unconfirmed
    kind/bug
    on May 20, 2021
  2. added
    bug/2-confirmed
    and removed
    bug/1-unconfirmed
    on May 23, 2021
  3. added this to the 2.31.0 / 3.0.x milestone on Aug 25, 2021
  4. tomhoule commented on Aug 25, 2021

    @tomhoule
  5. added
    tech/engines
    on Aug 25, 2021
  6. 44 remaining items

  7. jkomyno commented on Aug 23, 2022

    @jkomyno
    Contributor

    After adding snapshots for commands referencing empty schemas in this PR, no other actionable task seems available for this issue.

    Future steps might be:

    • Agree on a single, shared error message to display in case of "missing required blocks from the schema" (which is a generalization of having an empty schema)
    • This "missing required blocks" validation will most likely require access to the AST of the schema, so it should probably be performed by the Rust Prisma Engines and forwarded to the TS side

    Note: We should consider that this issue doesn't seem to fall in the "broken promises" bucket, so we could postpone additional work on this until after our joint effort with the client team is completed.

  8. Jolg42 commented on Aug 23, 2022

    @Jolg42
  9. jkomyno commented on Aug 23, 2022

    @jkomyno
    Contributor

    The current situation (as per main) is:

    PRISMA_CLI_QUERY_ENGINE_TYPE === 'library'

    • validate
    • migrate dev
          Get DMMF: Error while trying to read datamodel path
          Details: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
          Prisma CLI Version : 0.0.0
    
    • db push
    • migrate reset
          Couldn't find a datasource in the schema.prisma file
    
    • db pull
    • db execute
          There is no datasource in the schema.
    
    • format
         Formatted (.*) in \d+ms 🚀
    

    For PRISMA_CLI_QUERY_ENGINE_TYPE === 'binary' there are some differences to note:

    Different error:

    • migrate dev
       Couldn't find a datasource in the schema.prisma file
    

    The following are valid for the binary but not for the library

    • validate
         The schema at (.*) is valid 🚀
    
  10. jkomyno commented on Aug 26, 2022

    @jkomyno
    Contributor

    Next steps:

    • Figure out why validate and migrate dev fail with such an error when using the library. Can we change figure out that undefined parameter?
    • We need to identify the differences between getDmmf in the binary and library
    • Refactor empty-schema tests to incomplete-schema tests (test(cli): empty-schema -> incomplete-schemas #15059):
      • You have a datasource URL, but the env variable is not set
      • You don't have a datasource block
      • You have a datasource block, but no URL
  11. jkomyno commented on Oct 4, 2022

    @jkomyno
    Contributor

    Note: this task requires the Wasm-ification of getConfig to be handled first (as getConfig can heavily influence the incomplete-schema tests linked to this issue).

  12. added a commit that references this issue on Jul 22, 2026
    5831990
  13. added a commit that references this issue on Aug 9, 2026
    8eb2c40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedkind/bugtech/typescripttopic: clitopic: prisma db pulltopic: prisma db pushtopic: prisma migrate dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions