Error "invalid memory address or nil pointer dereference" using docker-compose
nyancow opened this issue · comments
Hi! This seems like an awesome service, especially for self-hosters like myself.
Running urlsh
using docker-compose
, the server and its requirements all seem to run fine, but when I click the "Shorten" button I receive a HTTP 500 error with the following message:
{"message":"runtime error: invalid memory address or nil pointer dereference","status":500}
I'm not seeing any logs in the docker-compose
run, even when launching using APP_ENV=dev
.
What could be causing this issue? Any way I can debug it?
Is it possible the error message is acutally coming from Docker (and not from urlsh)?
Thanks.
hello only by that error message it is difficult to know why or what happened.
can you try - ensuring db tables are created, go version 1.16, maybe helps.
Are there any changes I can make to the code to get a more verbose output of the error? Maybe a stack trace or line number?
I tried adding logLevel = logger.Error
to orm/postgres.go
, bu tthis didn't seem to have any effect on log output.
that will have more verbose in the console log not in the web/API response
I realize that, but I don't see any console output either.
I added a few fmt.Print
s throughout orm/postgres.go
to try and detect where it was failing.
dsn
was set to postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST:-urlshdb}:${POSTGRES_PORT:-5432}/${POSTGRES_DB}
(literally), so the environment variables weren't being resolved properly from my .env
file.
The solution was to modify my .env
so that DATABASE_URL
explicitly defines all of the required elements (without variables).
that's nice then :D