prisma / studio

πŸŽ™οΈ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.85k stars 47 forks source link

Unable to process `count` query undefined #890

Open zomars opened 2 years ago

zomars commented 2 years ago

When trying to use Studio this error happens:

image

Since we're open source we can share our prisma schema without problems:

https://github.com/calcom/cal.com/blob/main/packages/prisma/schema.prisma

We can run queries just fine, it just crashes when trying to open up Studio.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://cloud.prisma.io
  2. Fork this repo and setup a new project with it
  3. Set packages/prisma/schema.prisma as schema path.
  4. Go to Studio
  5. See error

Originally posted by @zomars in https://github.com/prisma/studio/issues/871#issuecomment-1075347171

janpio commented 2 years ago

We can run queries just fine

What exactly does this refer to? The Query Console of Prisma Data Platform?

Can you maybe share your project name and URL on cloud.prisma.io?

zomars commented 2 years ago

We can run queries just fine

What exactly does this refer to? The Query Console of Prisma Data Platform?

The Data Browser specifically is the one failing

Can you maybe share your project name and URL on cloud.prisma.io?

Sure thing, it is https://cloud.prisma.io/zomars/calcom/staging/databrowser

zomars commented 2 years ago

This only seems to happen when provisioning my own DB url, generating one from Heroku doesn't have this problem.

Using a DB url with this format: postgresql://user:pass@example.com:5432/calendso?schema=public

janpio commented 2 years ago

Interesting :/

Where do you host that database? Anything special about it or the user you use to connect to it? Do you have any output in the developer console when opening the data browser? Maybe the specific "query" that fails... Are you sure the database is fully migrated to the state of the schema file that the data browser is using (via the repo that you connected)?

zomars commented 2 years ago

We recently upgraded from prisma 3.2. So it May have something to do with it

MaxMusing commented 2 years ago

Running into this issue too.

The full error message in the browser console says:

The provided database string is invalid. Error parsing connection string: empty host in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.

The way we're setting our database URL is a little funky because we're using Doppler to manage secrets. Our schema.prisma file looks like this:

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

And our .env file looks like this:

DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}

Where those POSTGRES_ environment variables are defined in Doppler.

If I hard-code the url in schema.prisma to be a fully-defined database URL, then I'm able to load Prisma Studio.

janpio commented 2 years ago

Max, I think that sounds like an unrelated problem that just surfaces the same way. Can you please open a new issue? (Are you trying to start Studio locally, or are you on cloud.prisma.io in the Data Browser as Omar?)

oreqizer commented 2 years ago

@zomars are you by any chance using Safari? I had this error, and it only appears in Safari. works ok in Chrome

zomars commented 2 years ago

@zomars are you by any chance using Safari? I had this error, and it only appears in Safari. works ok in Chrome

Yes I'm using Safari. Didn't mention it since I don't think it should affect, but seems I'm wrong.

matthewp672261 commented 2 years ago

@zomars are you by any chance using Safari? I had this error, and it only appears in Safari. works ok in Chrome

switching from Safari to chrome fixed this issue for me

zomars commented 2 years ago

Yes using Safari. Not a Chrome user here

oreqizer commented 2 years ago

I found this is only happening if my database is misaligned with my Prisma schema β€” are you sure yours are in sync?

zomars commented 2 years ago

I found this is only happening if my database is misaligned with my Prisma schema β€” are you sure yours are in sync?

Yes. They are in sync. It seems this happens when a record has a large amount of relationships (More than 10k). Filtering out those columns works as a workaround.

neoromantic commented 2 years ago

Still happening. Confirming that this happens in Safari, but not in Chrome. Seems like a critical bug to me.

petradonka commented 2 years ago

@neoromantic, are you also using the Data Browser in Prisma Data Platform (if yes, could you share the owner and project name)? What database are you using? Do you have a large number of relationships?

zomars commented 2 years ago

This is still happening on latest prisma BTW:

image
jeffdrumgod commented 1 year ago

same here, but using a custom folder for Prisma, for MongoDB. The nodejs application works fine, but Prisma Studio show this error when it start Prisma studio.

✌️ Note: This error occurs only on Safari. Opening the same URL/project in Chrome, error disappear

petradonka commented 1 year ago

Thanks for the extra info! Do you have a relatively large number of relationships?

nmwur commented 1 year ago

npx prisma db push solved it for me

mcgri commented 1 year ago

npx prisma db push <- solved safari issue for me too.

Rezosh commented 1 year ago

This error occurred to me while trying to run it on a local version of mongodb that wasn't a replica set, as soon as I ran it on my replica set it worked in safari without issue.

argcast commented 1 year ago

This might happen while trying to load non existing tables on current database but existing on Prisma's schema. As mentioned above, make sure to npx prisma db push and then re-launch studio. Solved it for me too.

cerpow commented 1 year ago

Happened to me if you set the mongo url in env() function

url = env("DATABASE_URL")

should be : url = "DATABASE_URL"

lamebrowndev commented 1 year ago

@zomars are you by any chance using Safari? I had this error, and it only appears in Safari. works ok in Chrome

That is weird. Didn't know this could have been a problem

sscotth commented 1 year ago

Still happening. Confirming that this happens in Safari, but not in Chrome. Seems like a critical bug to me.

Same for me today. Safari showed error above, while Firefox did not.

Additional console error context:

image

Firefox shows the same console errors, but doesn't "Fatal error" like Safari

image

Either way, db push fixed the issue.

bab55z commented 1 year ago

Maybe you should try using dotenv cli to provide correct environment variables to Studio yarn global add dotenv-cli dotenv -e .env.local -- npx prisma studio

do-kevin commented 1 year ago

Can confirm.

npx prisma db push fixed it for Safari. Chrome already worked.

jingidy commented 1 year ago

If anyone's encountering this with supabase and pgbouncer, and using different ports for pooling and non-pooling, try changing the port numbers, that fixed it for me. Now I just need to check if the port actually pools or if my code reversed the two.

farhan-niloy commented 11 months ago

same here, but using a custom folder for Prisma, for MongoDB. The nodejs application works fine, but Prisma Studio show this error when it start Prisma studio.

✌️ Note: This error occurs only on Safari. Opening the same URL/project in Chrome, error disappear

drum bro, Thanks

nwazuo commented 3 months ago

I found this is only happening if my database is misaligned with my Prisma schema β€” are you sure yours are in sync?

This is the case with me too. Running prisma db push fixes itπŸš€.