studio icon indicating copy to clipboard operation
studio copied to clipboard

Unable to process `count` query undefined

Open zomars opened this issue 2 years ago β€’ 30 comments

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

zomars avatar Mar 22 '22 19:03 zomars

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?

janpio avatar Mar 22 '22 20:03 janpio

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 avatar Mar 22 '22 20:03 zomars

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:[email protected]:5432/calendso?schema=public

zomars avatar Mar 22 '22 20:03 zomars

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)?

janpio avatar Mar 24 '22 09:03 janpio

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

zomars avatar Mar 24 '22 15:03 zomars

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.

MaxMusing avatar Mar 24 '22 20:03 MaxMusing

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?)

janpio avatar Mar 24 '22 21:03 janpio

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

oreqizer avatar Jun 15 '22 19:06 oreqizer

@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.

zomars avatar Jun 15 '22 19:06 zomars

@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

matthewp672261 avatar Jul 14 '22 17:07 matthewp672261

Yes using Safari. Not a Chrome user here

zomars avatar Jul 14 '22 17:07 zomars

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

oreqizer avatar Jul 16 '22 18:07 oreqizer

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.

zomars avatar Jul 16 '22 19:07 zomars

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

neoromantic avatar Aug 16 '22 08:08 neoromantic

@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?

petradonka avatar Aug 16 '22 16:08 petradonka

This is still happening on latest prisma BTW: image

zomars avatar Aug 16 '22 18:08 zomars

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

jeffdrumgod avatar Sep 17 '22 18:09 jeffdrumgod

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

petradonka avatar Sep 19 '22 10:09 petradonka

npx prisma db push solved it for me

nmwur avatar Sep 29 '22 17:09 nmwur

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

mcgri avatar Oct 23 '22 13:10 mcgri

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.

Rezosh avatar Nov 02 '22 21:11 Rezosh

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.

argcast avatar Jan 15 '23 18:01 argcast

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

url = env("DATABASE_URL")

should be : url = "DATABASE_URL"

cerpow avatar Mar 06 '23 20:03 cerpow

@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

lamebrowndev avatar Apr 09 '23 10:04 lamebrowndev

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.

sscotth avatar May 02 '23 08:05 sscotth

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

bab55z avatar May 22 '23 15:05 bab55z

Can confirm.

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

do-kevin avatar Jul 10 '23 07:07 do-kevin

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.

jingidy avatar Aug 11 '23 21:08 jingidy

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

farhan-niloy avatar Sep 21 '23 17:09 farhan-niloy

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πŸš€.

nwazuo avatar May 06 '24 09:05 nwazuo