Panic on incorrect postgres connection settings #163

Closed
opened 2024-11-07 09:14:14 +01:00 by kamikazechaser · 1 comment
2024/11/07 11:08:13 postgres://postgres:postrgres@localhost:5432/urdt_ussd
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x998c7b]

goroutine 1 [running]:
git.defalsify.org/vise.git/db/postgres.(*pgDb).Prepare(0xc0003e26f0, {0xc22698, 0xc0003e26c0})
        /home/kamikaze/go/pkg/mod/git.defalsify.org/vise.git@v0.2.1-0.20241017112704-307fa6fcdc6b/db/postgres/pg.go:157 +0x1db
git.defalsify.org/vise.git/db/postgres.(*pgDb).Connect(0xc0003e26f0, {0xc22698, 0xc0003e26c0}, {0xc0003c68c0?, 0xc00004fb68?})
        /home/kamikaze/go/pkg/mod/git.defalsify.org/vise.git@v0.2.1-0.20241017112704-307fa6fcdc6b/db/postgres/pg.go:63 +0x86
git.grassecon.net/urdt/ussd/internal/storage.(*MenuStorageService).getOrCreateDb(0xc00004fde0, {0xc22698, 0xc0003e26c0}, {0x0, 0x0}, {0xb25d63, 0xd})
        /home/kamikaze/ge/ussd/internal/storage/storageservice.go:75 +0x1ea
git.grassecon.net/urdt/ussd/internal/storage.(*MenuStorageService).GetUserdataDb(0xc0003b1de0, {0xc22698?, 0xc0003e26c0?})
        /home/kamikaze/ge/ussd/internal/storage/storageservice.go:105 +0x45
main.main()
        /home/kamikaze/ge/ussd/cmd/africastalking/main.go:123 +0x796
exit status 2

Rather than panic, a failed to connect error should be returned to guide the user to update the settings and the process can then exit with error or panic.

``` 2024/11/07 11:08:13 postgres://postgres:postrgres@localhost:5432/urdt_ussd panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x998c7b] goroutine 1 [running]: git.defalsify.org/vise.git/db/postgres.(*pgDb).Prepare(0xc0003e26f0, {0xc22698, 0xc0003e26c0}) /home/kamikaze/go/pkg/mod/git.defalsify.org/vise.git@v0.2.1-0.20241017112704-307fa6fcdc6b/db/postgres/pg.go:157 +0x1db git.defalsify.org/vise.git/db/postgres.(*pgDb).Connect(0xc0003e26f0, {0xc22698, 0xc0003e26c0}, {0xc0003c68c0?, 0xc00004fb68?}) /home/kamikaze/go/pkg/mod/git.defalsify.org/vise.git@v0.2.1-0.20241017112704-307fa6fcdc6b/db/postgres/pg.go:63 +0x86 git.grassecon.net/urdt/ussd/internal/storage.(*MenuStorageService).getOrCreateDb(0xc00004fde0, {0xc22698, 0xc0003e26c0}, {0x0, 0x0}, {0xb25d63, 0xd}) /home/kamikaze/ge/ussd/internal/storage/storageservice.go:75 +0x1ea git.grassecon.net/urdt/ussd/internal/storage.(*MenuStorageService).GetUserdataDb(0xc0003b1de0, {0xc22698?, 0xc0003e26c0?}) /home/kamikaze/ge/ussd/internal/storage/storageservice.go:105 +0x45 main.main() /home/kamikaze/ge/ussd/cmd/africastalking/main.go:123 +0x796 exit status 2 ``` Rather than panic, a failed to connect error should be returned to guide the user to update the settings and the process can then exit with error or panic.
kamikazechaser added the
Kind/Enhancement
Priority
Low
Runner
HTTP
labels 2024-11-07 09:14:14 +01:00
kamikazechaser added
Runner
AT
and removed
Runner
HTTP
labels 2024-11-07 09:46:16 +01:00
Author
Owner

Fix applied on go-vise. Patch will be sent soon.

Fix applied on go-vise. Patch will be sent soon.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: urdt/ussd#163
No description provided.