Skip to content

[Bug Report] panic during error handling on second startup #983

@Dobatymo

Description

@Dobatymo

Describe the bug

Calling stash-box on second start-up with wrong password or non existent database results in panic.

>stash-box-windows.exe
panic: failed to open database, "postgres://postgres@localhost/stash-box?sslmode=disable": pq: Passwort-Authentifizierung f�r Benutzer �postgres� fehlgeschlagen [password authentication for user failed]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xd90083]

goroutine 1 [running]:
main.main.deferwrap1()
        /home/runner/work/stash-box/stash-box/main.go:28 +0x23
panic({0xe2c500?, 0xc0005a2090?})
        /opt/hostedtoolcache/go/1.23.11/x64/src/runtime/panic.go:791 +0x132
github.com/stashapp/stash-box/pkg/database.(*PostgresProvider).runMigrations(0x18?, {0xc00002ea20, 0x2c})
        /home/runner/work/stash-box/stash-box/pkg/database/postgres.go:77 +0x1a6
github.com/stashapp/stash-box/pkg/database.(*PostgresProvider).Open(0xe91f40?, {0xc00002ea20, 0x2c})
        /home/runner/work/stash-box/stash-box/pkg/database/postgres.go:34 +0x32
github.com/stashapp/stash-box/pkg/database.Initialize({0x101be4c, 0x8}, {0xc00002ea20, 0x2c})
        /home/runner/work/stash-box/stash-box/pkg/database/database.go:22 +0x64
main.main()
        /home/runner/work/stash-box/stash-box/main.go:33 +0xec
>stash-box-windows.exe
panic: failed to open database, "postgres://postgres:xxx@localhost/stash-box?sslmode=disable": pq: Datenbank �stash-box� existiert nicht [database does not exist]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xd90083]

goroutine 1 [running]:
main.main.deferwrap1()
        /home/runner/work/stash-box/stash-box/main.go:28 +0x23
panic({0xe2c500?, 0xc0004ea010?})
        /opt/hostedtoolcache/go/1.23.11/x64/src/runtime/panic.go:791 +0x132
github.com/stashapp/stash-box/pkg/database.(*PostgresProvider).runMigrations(0x18?, {0xc000120100, 0x33})
        /home/runner/work/stash-box/stash-box/pkg/database/postgres.go:77 +0x1a6
github.com/stashapp/stash-box/pkg/database.(*PostgresProvider).Open(0xe91f40?, {0xc000120100, 0x33})
        /home/runner/work/stash-box/stash-box/pkg/database/postgres.go:34 +0x32
github.com/stashapp/stash-box/pkg/database.Initialize({0x101be4c, 0x8}, {0xc000120100, 0x33})
        /home/runner/work/stash-box/stash-box/pkg/database/database.go:22 +0x64
main.main()
        /home/runner/work/stash-box/stash-box/main.go:33 +0xec

To Reproduce

  1. start stash-box first time to create default config
  2. have password on postgres user on postgres db
  3. start stash-box second time (first error)
  4. add password to connection string
  5. start stash-box again (second error)

Expected behavior
just show the normal error message and don't panic

Screenshots

Desktop (please complete the following information):

  • OS: Windows 11 x64
  • Browser: not used
  • Version v0.6.17 - 2025-08-10 09:22:42

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions