Skip to content

Commit c62641a

Browse files
authored
Fix: handle (and try to avoid) panic in sigv4 middleware (#269)
* Fix: handle (and try to avoid) panic in sigv4 middleware * Prepare 1.0.4 release
1 parent dd219d4 commit c62641a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 1.0.4
6+
- Fix: handle (and try to avoid) panic in sigv4 middleware by @njvrzm in [#269](https://github.com/grafana/grafana-aws-sdk/pull/269)
7+
- Remove pr_commands by @kevinwcyu in [#266](https://github.com/grafana/grafana-aws-sdk/pull/266)
8+
59
## 1.0.3
610

711
- Fix transport and cache bugs by @njvrzm in [#267](https://github.com/grafana/grafana-aws-sdk/pull/267)

pkg/awsauth/sigv4.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/sha256"
66
"encoding/hex"
7+
"fmt"
78
"io"
89
"net/http"
910
"time"
@@ -53,7 +54,12 @@ type SignerRoundTripper struct {
5354
clock Clock
5455
}
5556

56-
func (s SignerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
57+
func (s SignerRoundTripper) RoundTrip(req *http.Request) (resp *http.Response, e error) {
58+
defer func() {
59+
if err := recover(); err != nil {
60+
e = fmt.Errorf("panic caught in SignerRoundTripper.RoundTrip(): %v", err)
61+
}
62+
}()
5763
awsAuthSettings := Settings{
5864
AuthType: AuthType(s.httpOptions.SigV4.AuthType),
5965
AccessKey: s.httpOptions.SigV4.AccessKey,
@@ -63,6 +69,7 @@ func (s SignerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
6369
AssumeRoleARN: s.httpOptions.SigV4.AssumeRoleARN,
6470
ExternalID: s.httpOptions.SigV4.ExternalID,
6571
ProxyOptions: s.httpOptions.ProxyOptions,
72+
HTTPClient: &http.Client{},
6673
}
6774
ctx := req.Context()
6875
cfg, err := s.awsConfigProvider.GetConfig(ctx, awsAuthSettings)

0 commit comments

Comments
 (0)