Skip to content

Panic while connecting to invalid address #1062

@jbergstroem

Description

@jbergstroem

Describe the bug
While attempting to connect to an invalid address, permify panics after a few retries:

$ docker run -it -e PERMIFY_DATABASE_ENGINE=postgres -e PERMIFY_DATABASE_URI="postgres://user:foo@localhost:5432/db" permify/permify serve

██████╗ ███████╗██████╗ ███╗   ███╗██╗███████╗██╗   ██╗
██╔══██╗██╔════╝██╔══██╗████╗ ████║██║██╔════╝╚██╗ ██╔╝
██████╔╝█████╗  ██████╔╝██╔████╔██║██║█████╗   ╚████╔╝
██╔═══╝ ██╔══╝  ██╔══██╗██║╚██╔╝██║██║██╔══╝    ╚██╔╝
██║     ███████╗██║  ██║██║ ╚═╝ ██║██║██║        ██║
╚═╝     ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝╚═╝╚═╝        ╚═╝
_______________________________________________________
Fine-grained Authorization System v0.7.3
time=2024-02-20T12:18:22.395Z level=INFO msg="🚀 starting permify service..."
time=2024-02-20T12:18:22.395Z level=ERROR msg="Account ID is not set. Please fill in the Account ID for better support. Get your Account ID from https://permify.co/account"

time=2024-02-20T12:19:08.179Z level=ERROR msg="failed to migrate database: %w" !BADKEY="failed to connect to `host=localhost user=user database=db`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)"
time=2024-02-20T12:19:53.700Z level=ERROR msg="failed to initialize database: %w" !BADKEY="failed to connect to `host=localhost user=user database=db`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)"
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xbad6c8]

goroutine 1 [running]:
github.com/Permify/permify/pkg/cmd.NewServeCommand.serve.func1.2()
        /home/runner/work/permify/permify/pkg/cmd/serve.go:151 +0x28
panic({0xce7080?, 0x1a46240?})
        /opt/hostedtoolcache/go/1.21.6/x64/src/runtime/panic.go:920 +0x26c
github.com/Permify/permify/internal/factories.DataReaderFactory({0x0, 0x0})
        /home/runner/work/permify/permify/internal/factories/storage.go:14 +0x20
github.com/Permify/permify/pkg/cmd.NewServeCommand.serve.func1(0x400015c100?, {0x1aa2fe0?, 0x4?, 0xed26df?})
        /home/runner/work/permify/permify/pkg/cmd/serve.go:237 +0xcc8
github.com/spf13/cobra.(*Command).execute(0x40002f6300, {0x1aa2fe0, 0x0, 0x0})
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x40002f6000)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(0x40002f6000?)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1c
main.main()
        /home/runner/work/permify/permify/cmd/permify/permify.go:37 +0x204

To Reproduce
Steps to reproduce the behavior:

$ docker run -it \
  -e PERMIFY_DATABASE_ENGINE=postgres \
  -e PERMIFY_DATABASE_URI="postgres://user:foo@localhost:5432/db" \
  permify/permify

Expected behavior
It should either manage an exit or allow more options for retries.

Environment (please complete the following information, because it helps us investigate better):
Using Docker 25.0.3 on MacOS 14.3.1

Metadata

Metadata

Labels

bugSometing isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions