Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): unhandled errors from API calls #602

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

apricote
Copy link
Member

When these errors happen, a nil Action pointer was passed to hcclient.WaitForAction, which caused the error (and other similar):

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaf8c56]
goroutine 63 [running]:
github.com/hetznercloud/hcloud-go/hcloud.(*ActionClient).WatchOverallProgress.func1(0xc0000c6a80, 0xc000724840, 0xc0008281d0, 0x1, 0x1, 0xc000478178, 0x10fea38, 0xc000716fc0)
    github.com/hetznercloud/hcloud-go@v1.27.0/hcloud/action.go:196 +0x176
created by github.com/hetznercloud/hcloud-go/hcloud.(*ActionClient).WatchOverallProgress
    github.com/hetznercloud/hcloud-go@v1.27.0/hcloud/action.go:189 +0xde

By properly checking wether we encountered an error in the API call, we can instead return a proper error message to the user.

I checked all usages of hcclient.WaitForAction for missing error handlers, but these two were the only ones I found.

Closes #491

When these errors happen, a nil Action pointer was passed to
`hcclient.WaitForAction`, which caused the error (and other similar):

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xaf8c56]
    goroutine 63 [running]:
    github.com/hetznercloud/hcloud-go/hcloud.(*ActionClient).WatchOverallProgress.func1(0xc0000c6a80, 0xc000724840, 0xc0008281d0, 0x1, 0x1, 0xc000478178, 0x10fea38, 0xc000716fc0)
        github.com/hetznercloud/hcloud-go@v1.27.0/hcloud/action.go:196 +0x176
    created by github.com/hetznercloud/hcloud-go/hcloud.(*ActionClient).WatchOverallProgress
        github.com/hetznercloud/hcloud-go@v1.27.0/hcloud/action.go:189 +0xde

By properly checking wether we encountered an error in the API call, we
can instead return a proper error message to the user.

Closes #491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: panic: runtime error: invalid memory address or nil pointer dereference
2 participants