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

SigV4 panics on GET requests / requests with nil body #562

Open
tsipo opened this issue Jan 8, 2024 · 0 comments
Open

SigV4 panics on GET requests / requests with nil body #562

tsipo opened this issue Jan 8, 2024 · 0 comments

Comments

@tsipo
Copy link

tsipo commented Jan 8, 2024

Hi there,

This issue was already reported here but the title of that issue is misleading. The problem is not with building the client, the problem is that (*sigV4RoundTripper).RoundTrip() assumes that the request has a non-nil body, as it tries to copy it using io.Copy(). That's what causes the panic.

I got this calling the API Buildinfo(), which is using a GET request (with nil body). For that matter, AMP doesn't expose the build info API at all (returns 404, as I could see using awscurl), but I don't even get there as the RoundTripper panics before the request is even sent.

Calling QueryRange() (or any other POST request) with the same config works perfectly fine.

This is what I get:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x56b134]

goroutine 1 [running]:
bytes.(*Buffer).ReadFrom(0xc000495b30, {0x0, 0x0})
/usr/local/go/src/bytes/buffer.go:211 +0x114
io.copyBuffer({0x155e2e0, 0xc000495b30}, {0x0, 0x0}, {0x0, 0x0, 0x0})
/usr/local/go/src/io/io.go:416 +0x25a
io.Copy({0x155e2e0, 0xc000495b30}, {0x0, 0x0})
/usr/local/go/src/io/io.go:389 +0x79
github.com/prometheus/common/sigv4.(*sigV4RoundTripper).RoundTrip(0xc0000bf860, 0xc000472500)
/home/roy/go/pkg/mod/github.com/prometheus/common/sigv4@v0.1.0/sigv4.go:105 +0x19b
...
github.com/prometheus/client_golang/api.(*httpClient).Do(0xc0004c6140, {0x1564e00, 0xc0000bf7c0}, 0xc000472500)
/home/roy/go/pkg/mod/github.com/prometheus/client_golang@v1.18.0/api/client.go:125 +0xe9
github.com/prometheus/client_golang/api/prometheus/v1.(*apiClientImpl).Do(0xc0004c0530, {0x1564e00, 0xc0000bf7c0}, 0xc000472400)
/home/roy/go/pkg/mod/github.com/prometheus/client_golang@v1.18.0/api/prometheus/v1/api.go:1382 +0xd4
github.com/prometheus/client_golang/api/prometheus/v1.(*httpAPI).Buildinfo(0xc0004c0540, {0x1564e00, 0xc0000bf7c0})
/home/roy/go/pkg/mod/github.com/prometheus/client_golang@v1.18.0/api/prometheus/v1/api.go:999 +0x203
...

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

No branches or pull requests

1 participant