Skip to content

Missing credentials in Postgres URL: Got invalid RPC response without .result property #381

Closed

Description

@alizahid

Schema

datasource db {
  provider = "postgresql"
  url      = "postgresql://localhost:5432/bother?schema=public"
}

generator photonjs {
  provider = "photonjs"
}

model Post {
  id       String    @id @default(cuid())
  body     String
  comments Comment[]
  location Float[]
  rating   Int
  ratings  Rating[]
  user     User
  created  DateTime  @default(now())
}

model Rating {
  id        String   @id @default(cuid())
  direction Int
  post      Post
  user      User
  created   DateTime @default(now())
  updated   DateTime @default(now())
}

model Comment {
  id      String   @id @default(cuid())
  body    String
  post    Post
  user    User
  created DateTime @default(now())
}

model User {
  id            String   @id @default(cuid())
  notifications Boolean
  platform      String
  posts         Post[]
  push_token    String
  created       DateTime @default(now())
  updated       DateTime @default(now())
}

Versions

macOS 10.14.5 (18F132)
Prisma [email protected], binary version: 33e5fc84b6bd61602f8d634beb558230ca3e3054
PostgreSQL psql (PostgreSQL) 11.4

@pantharshit00 I'm not using embeds or dashes in my schema name. VSCode Prisma extension clears my schema, too. Any help?

Activity

  1. pantharshit00 commented on Aug 20, 2019

    @pantharshit00
    Contributor

    I am really unable to reproduce this.

    image
    image

    Can you try running the migration again with export RUST_BACKTRACE=1 so that we can get a full backtrace?

  2. added
    bug/0-unknown
    kind/bug
    on Aug 20, 2019
  3. alizahid commented on Aug 20, 2019

    @alizahid
    Author

    RUST_BACKTRACE=1 prisma2 lift save --name 'init' doesn't show any stack trace. Am I doing this wrong?

  4. pantharshit00 commented on Aug 20, 2019

    @pantharshit00
    Contributor

    Well in that case, can you please make sure that bother database exists in your database.

  5. alizahid commented on Aug 20, 2019

    @alizahid
    Author

    It exists. Prisma wouldn’t init without it.

  6. nachiket-p commented on Aug 21, 2019

    @nachiket-p

    Its working with local Postgres, but it doesn't work & same error appears with Heroku managed Postgres DB instances.

  7. pantharshit00 commented on Aug 21, 2019

    @pantharshit00
    Contributor

    Thanks, I was able to reproduce this now 🎉

    Reproduction steps:

    1. Create a new postgres instance on Heroku
    2. Initialise a new project using prisma2 init flow and the credentials obtained from above(remember that SSL is required)
    3. Run `prisma2 lift save --name 'init'
    4. See the error.

    image

    Version: [email protected], binary version: 33e5fc84b6bd61602f8d634beb558230ca3e3054

    Rust backtrace:

    LiftEngine:stderr thread 'main' panicked at 'Box<Any>', migration-engine/core/src/main.rs:57:23 +0ms
      LiftEngine:stderr stack backtrace: +29ms
      LiftEngine:stderr    0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace +1ms
      LiftEngine:stderr    1: std::sys_common::backtrace::_print +0ms
      LiftEngine:stderr    2: std::panicking::default_hook::{{closure}} +0ms
      LiftEngine:stderr    3: std::panicking::default_hook +0ms
      LiftEngine:stderr    4: std::panicking::rust_panic_with_hook +0ms
      LiftEngine:stderr    5: std::panicking::begin_panic +0ms
      LiftEngine:stderr    6: migration_engine::main +0ms
      LiftEngine:stderr    7: std::rt::lang_start::{{closure}} +0ms
      LiftEngine:stderr    8: std::panicking::try::do_call +0ms
      LiftEngine:stderr    9: __rust_maybe_catch_panic +0ms
      LiftEngine:stderr   10: std::rt::lang_start_internal +0ms
      LiftEngine:stderr   11: main +0ms
    
  8. added
    bug/2-confirmed
    and removed
    bug/0-unknown
    on Aug 21, 2019
  9. kleydon commented on Aug 22, 2019

    @kleydon

    I'm seeing the same error locally, with mysql.

  10. pantharshit00 commented on Aug 22, 2019

    @pantharshit00
    Contributor

    @kleydon

    Can you please share the output of the command using export DEBUG=* set?

  11. ryanking1809 commented on Aug 22, 2019

    @ryanking1809

    I'm also getting this error trying to deploy to Heroku but am using RDS for a postgres db. Possibly due to photon generating into a temp folder?

    repo: https://github.com/ryanking1809/prisma2-zeit-now

    Counting objects: 12, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (12/12), done.
    Writing objects: 100% (12/12), 1.21 KiB | 620.00 KiB/s, done.
    Total 12 (delta 7), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: -----> Node.js app detected
    remote:        
    remote: -----> Creating runtime environment
    remote:        
    remote:        NPM_CONFIG_LOGLEVEL=error
    remote:        NODE_ENV=production
    remote:        NODE_MODULES_CACHE=true
    remote:        NODE_VERBOSE=false
    remote:        
    remote: -----> Installing binaries
    remote:        engines.node (package.json):  unspecified
    remote:        engines.npm (package.json):   unspecified (use default)
    remote:        engines.yarn (package.json):  unspecified (use default)
    remote:        
    remote:        Resolving node version 10.x...
    remote:        Downloading and installing node 10.16.3...
    remote:        Using default npm version: 6.9.0
    remote:        Resolving yarn version 1.x...
    remote:        Downloading and installing yarn (1.17.3)...
    remote:        Installed yarn 1.17.3
    remote:        
    remote: -----> Restoring cache
    remote:        - yarn cache
    remote:        
    remote: -----> Installing dependencies
    remote:        Installing node modules (yarn.lock)
    remote:        yarn install v1.17.3
    remote:        [1/4] Resolving packages...
    remote:        [2/4] Fetching packages...
    remote:        [3/4] Linking dependencies...
    remote:        [4/4] Building fresh packages...
    remote:        $ prisma2 generate && prisma2 lift up
    remote:        Generating Photon.js Client to /tmp/build_faf6b398170190afc1f8a7a3163d100f/node_modules/@generated/photon
    remote:        
    remote:        
    remote:        
    remote:        
    remote:        Done in 8.26s
    remote:        Generating Nexus Prisma to /tmp/build_faf6b398170190afc1f8a7a3163d100f/node_modules/@generated/nexus-prisma
    remote:        Done in 56ms
    remote:        
    remote:        Error: Got invalid RPC response without .result property: {}
    remote:        error Command failed with exit code 1.
    remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    remote: 
    remote: -----> Build failed
    remote:        
    remote:        We're sorry this build is failing! You can troubleshoot common issues here:
    remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
    remote:        
    remote:        Some possible problems:
    remote:        
    remote:        - Node version not specified in package.json
    remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
    remote:        
    remote:        Love,
    remote:        Heroku
    remote:        
    remote:  !     Push rejected, failed to compile Node.js app.
    remote: 
    remote:  !     Push failed
    
  12. pantharshit00 commented on Aug 22, 2019

    @pantharshit00
    Contributor

    @ryanking1809 It is more related to the database connection.

    Can you share the output of the lift command with export DEBUG=* enabled?

  13. ryanking1809 commented on Aug 22, 2019

    @ryanking1809

    @pantharshit00 sorry a bit of a newbie here. Where / how do I enable export DEBUG=*?

  14. 16 remaining items

  15. BradDC commented on Aug 25, 2019

    @BradDC

    Heads up, confirmed still an issue with [email protected] and [email protected], attached output. Introspect works fine... credentials correct as well.

    ➜  graphql git:(master) ✗ prisma2 lift save
    Error: Got invalid RPC response without .result property: {}
    ➜  graphql git:(master) ✗ DEBUG=* prisma2 lift save --name "init"
      LiftEngine:rpc SENDING RPC CALL {
      id: 1,
      jsonrpc: '2.0',
      method: 'listMigrations',
      params: {
        projectInfo: '',
        sourceConfig: 'datasource db {\n' +
          '  provider = "postgresql"\n' +
          '  url      = "postgresql://exampleuser:[email protected]:5432/databasename?schema=public&sslmode=prefer"\n' +
          '}\n' +
          '\n' +
          'generator photon {\n' +
          '  provider = "photonjs"\n' +
          '}\n' +
          '\n' +
          'generator nexus_prisma {\n' +
          '  provider = "nexus-prisma"\n' +
          '}\n' +
          '\n' +
          'model User {\n' +
          '  id    String  @default(cuid()) @id @unique\n' +
          '  email String  @unique\n' +
          '  name  String?\n' +
          '  posts Post[]\n' +
          '}\n' +
          '\n' +
          'model Post {\n' +
          '  id        String   @default(cuid()) @id @unique\n' +
          '  createdAt DateTime @default(now())\n' +
          '  updatedAt DateTime @updatedAt\n' +
          '  published Boolean\n' +
          '  title     String\n' +
          '  content   String?\n' +
          '  author    User?\n' +
          '}'
      }
    } +0ms
      LiftEngine:stderr [2019-08-25T23:24:41Z ERROR r2d2] Error querying the database: db error: FATAL: permission denied for database "postgres" +0ms
      LiftEngine:stderr [2019-08-25T23:24:41Z ERROR r2d2] Error querying the database: db error: FATAL: permission denied for database "postgres" +14ms
      LiftEngine:stderr thread 'main' panicked at 'Box<Any>', migration-engine/core/src/main.rs:55:23 +289ms
      LiftEngine:stderr stack backtrace: +0ms
      LiftEngine:stderr    0: std::panicking::default_hook::{{closure}} +26ms
      LiftEngine:stderr    1: std::panicking::default_hook +0ms
      LiftEngine:stderr    2: std::panicking::rust_panic_with_hook +0ms
      LiftEngine:stderr    3: std::panicking::begin_panic +0ms
      LiftEngine:stderr    4: migration_engine::main +0ms
      LiftEngine:stderr    5: std::rt::lang_start::{{closure}} +0ms
      LiftEngine:stderr    6: std::panicking::try::do_call +0ms
      LiftEngine:stderr    7: __rust_maybe_catch_panic +0ms
      LiftEngine:stderr    8: std::rt::lang_start_internal +0ms
      LiftEngine:stderr    9: main +0ms
    Error: Error: Got invalid RPC response without .result property: {}
        at /Users/brad/n/lib/node_modules/prisma2/build/index.js:134190:36
        at /Users/brad/n/lib/node_modules/prisma2/build/index.js:134077:13
        at Array.map (<anonymous>)
        at LiftEngine.rejectAll (/Users/brad/n/lib/node_modules/prisma2/build/index.js:134076:40)
        at ChildProcess.<anonymous> (/Users/brad/n/lib/node_modules/prisma2/build/index.js:134138:30)
        at ChildProcess.emit (events.js:203:13)
        at ChildProcess.EventEmitter.emit (domain.js:471:20)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
    ➜  graphql git:(master) ✗ npm -g list prisma2
    /Users/brad/n/lib
    └── [email protected]
    
    ➜  graphql git:(master) ✗ DEBUG=* prisma2 introspect
      PostgresIntrospection Listing schemas. +0ms
      RelationalIntrospection Querying schemas. +0ms
    ⠋ Introspecting database public  RelationalIntrospection Introspecting models in schema public. +206ms
      RelationalIntrospection Querying tables. +0ms
      PostgresIntrospection Querying column comments for public +208ms
      RelationalIntrospection Querying columns for schema public. +1ms
      PostgresIntrospection Querying indices for table public. +0ms
      RelationalIntrospection Querying relations in schema public. +1ms
      PostgresIntrospection Querying enums for schema public. +1ms
      PostgresIntrospection Querying sqeuences. +0ms
    ⠙ Introspecting database public  PostgresIntrospection Creating postgres specific introspection result. +3s
      RelationalIntrospectionResult Datamodel inferrence started. +0ms
      RelationalIntrospectionResult Basic types inferred. +1ms
      RelationalIntrospectionResult Id fields resolved. +0ms
      RelationalIntrospectionResult Default values inferred. +0ms
      RelationalIntrospectionResult Relations resolved. +1ms
      RelationalIntrospectionResult Relations enums resolved. +0ms
      RelationalIntrospectionResult Extra artifacts hidden. +0ms
      RelationalIntrospectionResult Validation done. +1ms
      RelationalIntrospectionResult Normalization done. +0ms
      RelationalIntrospectionResult Inferring done. +0ms
    ✔ Introspecting database public: 2.6s
    
    Created datamodel definition based on 0 database tables
    Created 1 new file: Prisma DML datamodel (derived from existing database)
    
      datamodel-1566775553.prisma
    
    ➜  graphql git:(master) ✗ ➜  graphql git:(master) ✗ npm -g list prisma2
    /Users/brad/n/lib
    └── [email protected]
    
    ➜  graphql git:(master) ✗ DEBUG=* prisma2 introspect
      PostgresIntrospection Listing schemas. +0ms
      RelationalIntrospection Querying schemas. +0ms
    ⠋ Introspecting database public  RelationalIntrospection Introspecting models in schema public. +206ms
      RelationalIntrospection Querying tables. +0ms
      PostgresIntrospection Querying column comments for public +208ms
      RelationalIntrospection Querying columns for schema public. +1ms
      PostgresIntrospection Querying indices for table public. +0ms
      RelationalIntrospection Querying relations in schema public. +1ms
      PostgresIntrospection Querying enums for schema public. +1ms
      PostgresIntrospection Querying sqeuences. +0ms
    ⠙ Introspecting database public  PostgresIntrospection Creating postgres specific introspection result. +3s
      RelationalIntrospectionResult Datamodel inferrence started. +0ms
      RelationalIntrospectionResult Basic types inferred. +1ms
      RelationalIntrospectionResult Id fields resolved. +0ms
      RelationalIntrospectionResult Default values inferred. +0ms
      RelationalIntrospectionResult Relations resolved. +1ms
      RelationalIntrospectionResult Relations enums resolved. +0ms
      RelationalIntrospectionResult Extra artifacts hidden. +0ms
      RelationalIntrospectionResult Validation done. +1ms
      RelationalIntrospectionResult Normalization done. +0ms
      RelationalIntrospectionResult Inferring done. +0ms
    ✔ Introspecting database public: 2.6s
    
    Created datamodel definition based on 0 database tables
    Created 1 new file: Prisma DML datamodel (derived from existing database)
    
      datamodel-1566775553.prisma
    
  16. BradDC commented on Aug 25, 2019

    @BradDC

    further information : wasn't able to replicate this issue with a local docker image of postgres 11.. might have something to do with the connection string or heroku..

  17. ryanking1809 commented on Aug 26, 2019

    @ryanking1809

    I might also add I've avoided the issue with a dockerfile (in Heroku) containing the following:

    FROM node:10.16.0
    RUN npm install -g --unsafe-perm prisma2
    
    RUN mkdir /app
    WORKDIR /app
    
    COPY package*.json ./
    COPY ./src/ ./src/
    COPY prisma ./prisma/
    
    ARG POSTGRES_URL
    ENV POSTGRES_URL "$POSTGRES_URL"
    
    RUN npm install
    RUN prisma2 generate
    RUN prisma2 lift up
    
    CMD ["npm", "start" ]
    
  18. added and removed
    kind/bug
    on Aug 27, 2019
  19. BradDC commented on Aug 27, 2019

    @BradDC

    reconfirmed - this definitely does look to be something specific at least to heroku database instances, not version of postgresql or connection string from what I can see, local docker postgres works fine as does digital ocean hosted postgres...

  20. ryanking1809 commented on Aug 28, 2019

    @ryanking1809

    I got this working, you need to make sure you have the correct environment variables set up in Heroku first, before deploy 🤦🏼‍♂️So this repo will work provided you set up the POSTGRES_URL before deploy. Sorry, should have picked up on that one earlier!

    https://github.com/ryanking1809/prisma2-zeit-now

  21. added this to the Preview 10 milestone on Aug 30, 2019
  22. divyenduz commented on Sep 4, 2019

    @divyenduz

    This is not reproducible anymore with

    divyendusingh [p2-pg]$ prisma2 --version
    [email protected], binary version: bbbeff6f84b408e534ebd866bfd378748e6d6611
    

    I tried these situations (wrong user, missing port, local or remote pg, missing env, wrong env).

    I am closing this one, if you still run into this issue, please create a new GH issue possibly with a minimal reproduction and tag me there 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug/2-confirmed

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions