prisma1
prisma1 copied to clipboard
"Expected host to be non-empty" after prisma init + mongodb existing database
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:
-
prisma init test
- Select use existing database with mongodb, enter connection uri
-
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
This is expected. The schema is used only for MySQL and Postgres.
So shouldn't the generated yaml not contain the schema field? Doesn't this stop people with existing MongoDBs from giving prisma a shot?
MongoDB has collections rather than a Schema.
Maybe we can add a more clear message to the validation cc @do4gr
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.
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'
Had the same problem today and solved it removing the schema key, please reopen this issue it's still happening with MongoDB configs
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.
temporary solution is to just remove schema
key in docker-compose.yml
.
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
Tons of confidence after getting an error after the first step. :-)
I changed "schema" to "database" per #4363 . Seems to work fine.
_____ _____
< `/ |
> (
| _ _ |
| |_) | |_) |
| | \ | | |
| |
______.______%_| |__________ _____
_/ \| |
| one hour of my time <
|_____.-._________ ____/|___________|
| |
| |
| |
| |
| _ <
|__/ |
/ `--. |
%| |%
|/.%%| -< @%%%
`\%`@| v |@@%@%%
.%%%@@@|% | % @@@%%@%%%%
_.%%%%%%@@@@@@%%_/%\_%@@%%@@@@@@@%%%%%%
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.
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.
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)
Same issue, removing the schema solved the problem for me, but would be helpful if that configuration was not generated in the first place.
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'