-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hi,
I've been hitting problems with some API calls to Hub timing out resulting in a panic due to an error being returned along with *http.Response
being nil
.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x12fbc67]
goroutine 1 [running]:
github.com/blackducksoftware/hub-client-go/hubclient.readResponseBody(0x0, 0xc000208500, 0x0, 0x141d980)
/Users/xxxxxxx/workspace/go/src/github.com/blackducksoftware/hub-client-go/hubclient/client.go:420 +0x37
github.com/blackducksoftware/hub-client-go/hubclient.(*Client).HttpGetJSON(0xc0000ae370, 0xc0002d61c0, 0x70, 0x132ce40, 0xc00000c460, 0xc8, 0x70, 0xc00006ac00)
/Users/xxxxxxx/workspace/go/src/github.com/blackducksoftware/hub-client-go/hubclient/client.go:225 +0x3ed
github.com/blackducksoftware/hub-client-go/hubclient.(*Client).ListProjectVersions(0xc0000ae370, 0xc00001a410, 0x8, 0xc000020300, 0x5e, 0x0, 0x0, 0x0, 0x0, 0xc00000c3e0, ...)
/Users/xxxxxxx/workspace/go/src/github.com/blackducksoftware/hub-client-go/hubclient/projects-client.go:98 +0x171
main.main()
/Users/xxxxxxx/workspace/go/src/xxxxxxx/xxxxxxx/hub-query/main.go:68 +0xc7e
exit status 2
resp
is nil
here with the panic in readResponseBody
occurring when an attempt to access resp.Body
is made:
hub-client-go/hubclient/client.go
Lines 174 to 177 in e27076a
if resp, err = c.httpClient.Do(req); err != nil { | |
body := readResponseBody(resp) | |
return newHubClientError(body, resp, fmt.Sprintf("error getting HTTP Response from %s: %+v", url, err)) | |
} |
I've tweaked the hubclient
locally (handled the nil in this single location and set a dial timeout) and was able to see that in my case the underlying error being thrown (resulting in resp == nil
) was:
net/http: request canceled (Client.Timeout exceeded while awaiting headers)
The error handling should be tweaked to account for the possibility of resp
being nil
.
Metadata
Metadata
Assignees
Labels
No labels