common
common copied to clipboard
SigV4 client builder panics
Hello,
I am trying to implement the sigv4 package and construct a new sigv4 client. My code looks like this:
// If using Amazon Managed Prometheus Address, create sigv4 roundtripper
if strings.Contains(address, "aps-workspaces") {
var cfg sigv4.SigV4Config
var next http.RoundTripper
sigv4RoundTripper, err := sigv4.NewSigV4RoundTripper(&cfg, next)
if err != nil {
log.Errorf("Error creating SigV4 RoundTripper: %v", err)
}
pc.RoundTripper = sigv4RoundTripper
}
I am getting a panic when running this and i'm not sure why:
2023-03-30T16:27:57.664424-04:00 ??? Log level set to info
2023-03-30T16:27:57.664611-04:00 INF Starting cost-model version dev (HEAD)
2023-03-30T16:27:57.664693-04:00 INF Prometheus/Thanos Client Max Concurrency set to 5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x104dd3fa0]
goroutine 54 [running]:
bytes.(*Buffer).ReadFrom(0x14000e81590, {0x0, 0x0})
/opt/homebrew/Cellar/go/1.19.5/libexec/src/bytes/buffer.go:202 +0x70
io.copyBuffer({0x1071e1200, 0x14000e81590}, {0x0, 0x0}, {0x0, 0x0, 0x0})
/opt/homebrew/Cellar/go/1.19.5/libexec/src/io/io.go:413 +0x108
io.Copy(...)
/opt/homebrew/Cellar/go/1.19.5/libexec/src/io/io.go:386
github.com/prometheus/common/sigv4.(*sigV4RoundTripper).RoundTrip(0x14000dbb540, 0x14000635e00)
net/http.(*Client).Do(...)
I was thinking it's possible because I am implementing an empty sigv4.SigV4Config
but I believe I should be able to implement this empty and it should just take the default AWS provider chain. Any idea why I am getting a panic here?