prisma-engines icon indicating copy to clipboard operation
prisma-engines copied to clipboard

`expected value at line 1 column 1` on overriden datasources with some connection strings

Open steebchen opened this issue 2 years ago • 4 comments

The Go client overrides the datasources. This works fine, but it seems to break with some datasource URLs, e.g.

 ~/projects/prisma/prisma-go-demo | on main *1 !2 ?1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- at 02:01:34 
> export DATABASE_URL="postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable"

 ~/projects/prisma/prisma-go-demo | on main *1 !2 ?1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- at 02:01:38 
> go run .                                                                                
2023/12/25 02:01:40 expected value at line 1 column 1
panic: spawn: query engine errored: expected value at line 1 column 1

goroutine 1 [running]:
main.main()
        /Users/steebchen/projects/prisma/prisma-go-demo/main.go:14 +0x38
exit status 2

The full error message is always:

{"is_panic":false,"message":"expected value at line 1 column 1","backtrace":"   0: <unknown>\n   1: <unknown>\n   2: <unknown>\n   3: <unknown>\n   4: <unknown>\n   5: <unknown>\n"}

Now the weirdest part is that a similarly looking but slightly different datasource URL is working:

export DATABASE_URL="postgresql://test:test@test:5432/test?sslmode=disable"

go run .

// works!

I am going a bit crazy now debugging this, not really sure if encoding of the datasource URL has anything to do with this or if this ist just random at this point...

Any pointers would be highly appreciated, I can also prepare a full small reproduction with the Go client if needed.

steebchen avatar Dec 24 '23 19:12 steebchen

I can indeed reproduce with

git clone [email protected]:steebchen/prisma-go-demo.git
cd prisma-go-demo

Then edit the datasource to

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

and finally

export DATABASE_URL="postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable"
go run github.com/steebchen/prisma-client-go generate
go run .

Jolg42 avatar Jan 03 '24 13:01 Jolg42

Things get weird when trying different connection strings

This work, with mypostgres as host

export DATABASE_URL="postgresql://hatchet:hatchet@mypostgres:5432/hatchet?sslmode=disable" 

And this doesn't work, with postgres as host

export DATABASE_URL="postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable" 

Jolg42 avatar Jan 03 '24 13:01 Jolg42

@Jolg42 Can you reproduce in the JS client as well? Or did you test it using the Go client?

steebchen avatar Jan 03 '24 13:01 steebchen

I only tried using the go client, I doubt that it is reproducible with the JS client. Did you reproduce this using the JS Client?

Jolg42 avatar Jan 03 '24 13:01 Jolg42