prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

"Expected host to be non-empty" after prisma init + mongodb existing database

Open dmisdm opened this issue 5 years ago • 16 comments

Describe the bug Docker container continuously restarting after prisma init using mongodb existing database. Error:

prisma_1  | Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
prisma_1  | 	at scala.sys.package$.error(package.scala:26)
prisma_1  | 	at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
prisma_1  | 	at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
prisma_1  | 	at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
prisma_1  | 	at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
prisma_1  | 	at scala.Function0.apply$mcV$sp(Function0.scala:34)
prisma_1  | 	at scala.Function0.apply$mcV$sp$(Function0.scala:34)
prisma_1  | 	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
prisma_1  | 	at scala.App.$anonfun$main$1$adapted(App.scala:76)
prisma_1  | 	at scala.collection.immutable.List.foreach(List.scala:388)
prisma_1  | 	at scala.App.main(App.scala:76)
prisma_1  | 	at scala.App.main$(App.scala:74)
prisma_1  | 	at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
prisma_1  | 	at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)

To Reproduce Steps to reproduce the behavior:

  1. prisma init test
  2. Select use existing database with mongodb, enter connection uri
  3. docker-compose up -d

Expected behavior Given the connection and environment is sane/valid, no errors should occur.

Versions (please complete the following information):

  • Connector: MongoDB
  • Prisma Server: 1.30
  • prisma CLI: prisma/1.30.0 (darwin-x64) node-v11.13.0
  • OS: macOS Mojave

Workaround I managed to fix this by removing the schema field in the default database config in the docker-compose service environment variable. From:

        databases:
          default:
            connector: mongo
            schema: default_default
            uri: >-
              mongodb+srv://host/db?fake=true

To:

        databases:
          default:
            connector: mongo
            uri: >-
              mongodb+srv://host/db?fake=true

dmisdm avatar Apr 09 '19 00:04 dmisdm

This is expected. The schema is used only for MySQL and Postgres.

pantharshit00 avatar Apr 10 '19 18:04 pantharshit00

So shouldn't the generated yaml not contain the schema field? Doesn't this stop people with existing MongoDBs from giving prisma a shot?

dmisdm avatar Apr 10 '19 22:04 dmisdm

MongoDB has collections rather than a Schema.

Maybe we can add a more clear message to the validation cc @do4gr

pantharshit00 avatar Apr 11 '19 13:04 pantharshit00

prisma init adds the schema field even when pick the existing mongo option. I would suggest this isn't closed.

I just did a clean install and it added it again. If a mongo deployment doesn't need the schema field, it shouldn't add it.

jamesmhaley avatar Apr 17 '19 10:04 jamesmhaley

I have this same issue and removing "schema" did nothing for me. Here's my prisma.yml file:

version: "3"
services:
  prisma:
    image: prismagraphql/prisma:1.33
    restart: always
    ports:
      - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            schema: myapp
            uri: 'mongodb://host.docker.internal:27017/admin'

dpacmittal avatar May 25 '19 11:05 dpacmittal

Had the same problem today and solved it removing the schema key, please reopen this issue it's still happening with MongoDB configs

mrjomp avatar May 25 '19 17:05 mrjomp

prisma init adds the schema field even when pick the existing mongo option. I would suggest this isn't closed.

This is being tracked by a separate issue https://github.com/prisma/prisma/issues/4363. That is why I have closed this one.

pantharshit00 avatar May 28 '19 10:05 pantharshit00

temporary solution is to just remove schema key in docker-compose.yml.

vamshi9666 avatar May 30 '19 02:05 vamshi9666

Yes, temporary solution is to just remove schema key in docker-compose.yml. I have wasted an hour, i would have checked here :(

It works fine for me after removing schema key in docker-compose.yml

thavamm avatar Jun 16 '19 10:06 thavamm

Tons of confidence after getting an error after the first step. :-)

phishy avatar Jun 24 '19 21:06 phishy

I changed "schema" to "database" per #4363 . Seems to work fine.

                             _____  _____
                            <     `/     |
                             >          (
                            |   _     _  |
                            |  |_) | |_) |
                            |  | \ | |   |
                            |            |
             ______.______%_|            |__________  _____
           _/                                       \|     |
          |              one hour of my time               <
          |_____.-._________              ____/|___________|
                            |            |
                            |            |
                            |            |
                            |            |
                            |   _        <
                            |__/         |
                             / `--.      |
                           %|            |%
                       |/.%%|          -< @%%%
                       `\%`@|     v      |@@%@%%  
                     .%%%@@@|%    |    % @@@%%@%%%%
                _.%%%%%%@@@@@@%%_/%\_%@@%%@@@@@@@%%%%%%

asktree avatar Aug 15 '19 14:08 asktree

Even though this is a duplicate(https://github.com/prisma/prisma/issues/4363) I am going to open it as many people are seeing this issue more than the other one.

pantharshit00 avatar Aug 23 '19 10:08 pantharshit00

Yup, still happening when selecting an existing MongoDB database on a fresh prisma init. Noticed docker ps was showing no bound ports for the process, and then docker logs --tail 50 --follow <id> showed the container continuously restarting as described above. Removing the schema key did work for me, however.

Pocket-titan avatar Oct 22 '19 14:10 Pocket-titan

For removing or renaming it to database did not help. Maybe you have tips to me:

yml:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.34
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            uri: 'mongodb://localhost:27017/admin'

Prisma deploy:

prisma deploy
 !    Could not connect to server at http://localhost:4466. Please check if your server is running.

docker compose logs:

prisma_1 | Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty prisma_1 | at scala.sys.package$.error(package.scala:26) prisma_1 | at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40) prisma_1 | at com.prisma.local.PrismaLocalDependencies.(PrismaLocalDependencies.scala:48) prisma_1 | at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13) prisma_1 | at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8) prisma_1 | at scala.Function0.apply$mcV$sp(Function0.scala:34) prisma_1 | at scala.Function0.apply$mcV$sp$(Function0.scala:34) prisma_1 | at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) prisma_1 | at scala.App.$anonfun$main$1$adapted(App.scala:76) prisma_1 | at scala.collection.immutable.List.foreach(List.scala:388) prisma_1 | at scala.App.main(App.scala:76) prisma_1 | at scala.App.main$(App.scala:74) prisma_1 | at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8) prisma_1 | at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala)

kwoxer avatar Oct 23 '19 05:10 kwoxer

Same issue, removing the schema solved the problem for me, but would be helpful if that configuration was not generated in the first place.

kalebjdavenport avatar Mar 03 '20 23:03 kalebjdavenport

Replacing "schema" with "database" while deploying worked for me. Then did a prisma deploy. Here's my docker-compose.yml


version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.34
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            database: prismadb
            uri: 'mongodb://host.docker.internal:27017/prismadb'

abhik-99 avatar Apr 27 '20 17:04 abhik-99