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 client builder panics #465

Open
lewinkedrs opened this issue Mar 30, 2023 · 1 comment
Open

SigV4 client builder panics #465

lewinkedrs opened this issue Mar 30, 2023 · 1 comment

Comments

@lewinkedrs
Copy link

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?

@tsipo
Copy link

tsipo commented Jan 8, 2024

The problem is not with building the client, I opened a new issue - see here

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

2 participants