From 885de40869f9bcee29ad11d60967aa0f1b571d46 Mon Sep 17 00:00:00 2001 From: Dj Date: Wed, 18 Dec 2024 12:02:46 -0800 Subject: [PATCH] Fix improper use of Printf-style functions (#2934) --- .changelog/96979b8ab9d04d28990dfe28ae1aca84.json | 15 +++++++++++++++ config/resolve_test.go | 4 ++-- .../ssocreds/sso_credentials_provider_test.go | 2 +- feature/s3/manager/upload.go | 4 ++-- internal/awstesting/assert.go | 16 ++++++++-------- internal/endpoints/v2/package_test.go | 6 +++--- .../kinesis/internal/testing/eventstream_test.go | 8 ++++---- .../internal/testing/eventstream_test.go | 8 ++++---- 8 files changed, 39 insertions(+), 24 deletions(-) create mode 100644 .changelog/96979b8ab9d04d28990dfe28ae1aca84.json diff --git a/.changelog/96979b8ab9d04d28990dfe28ae1aca84.json b/.changelog/96979b8ab9d04d28990dfe28ae1aca84.json new file mode 100644 index 00000000000..8a8a25a3b83 --- /dev/null +++ b/.changelog/96979b8ab9d04d28990dfe28ae1aca84.json @@ -0,0 +1,15 @@ +{ + "id": "96979b8a-b9d0-4d28-990d-fe28ae1aca84", + "type": "bugfix", + "collapse": true, + "description": "Fix improper use of printf-style functions.", + "modules": [ + ".", + "config", + "credentials", + "feature/s3/manager", + "internal/endpoints/v2", + "service/kinesis/internal/testing", + "service/transcribestreaming/internal/testing" + ] +} \ No newline at end of file diff --git a/config/resolve_test.go b/config/resolve_test.go index 839378f99e4..e14199ce923 100644 --- a/config/resolve_test.go +++ b/config/resolve_test.go @@ -514,11 +514,11 @@ func TestResolveDefaultsMode(t *testing.T) { } if diff := cmpDiff(tt.ExpectedDefaultsMode, cfg.DefaultsMode); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } if diff := cmpDiff(tt.ExpectedRuntimeEnvironment, cfg.RuntimeEnvironment); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/credentials/ssocreds/sso_credentials_provider_test.go b/credentials/ssocreds/sso_credentials_provider_test.go index b894a32019e..493535b861d 100644 --- a/credentials/ssocreds/sso_credentials_provider_test.go +++ b/credentials/ssocreds/sso_credentials_provider_test.go @@ -189,7 +189,7 @@ func TestProvider(t *testing.T) { } if diff := cmpDiff(tt.ExpectedCredentials, credentials); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/feature/s3/manager/upload.go b/feature/s3/manager/upload.go index d73a6d3b913..18aff6e95be 100644 --- a/feature/s3/manager/upload.go +++ b/feature/s3/manager/upload.go @@ -3,6 +3,7 @@ package manager import ( "bytes" "context" + "errors" "fmt" "io" "net/http" @@ -10,7 +11,6 @@ import ( "sync" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/internal/awsutil" internalcontext "github.com/aws/aws-sdk-go-v2/internal/context" @@ -686,7 +686,7 @@ func (u *multiuploader) shouldContinue(part int32, nextChunkLen int, err error) msg = fmt.Sprintf("exceeded total allowed S3 limit MaxUploadParts (%d). Adjust PartSize to fit in this limit", MaxUploadParts) } - return false, fmt.Errorf(msg) + return false, errors.New(msg) } return true, err diff --git a/internal/awstesting/assert.go b/internal/awstesting/assert.go index 9b884c3def4..1d9bfb191ad 100644 --- a/internal/awstesting/assert.go +++ b/internal/awstesting/assert.go @@ -28,12 +28,12 @@ func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) b expectURL, err := url.Parse(expect) if err != nil { - t.Errorf(errMsg("unable to parse expected URL", err, msgAndArgs)) + t.Error(errMsg("unable to parse expected URL", err, msgAndArgs)) return false } actualURL, err := url.Parse(actual) if err != nil { - t.Errorf(errMsg("unable to parse actual URL", err, msgAndArgs)) + t.Error(errMsg("unable to parse actual URL", err, msgAndArgs)) return false } @@ -52,12 +52,12 @@ func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{}) expectQ, err := url.ParseQuery(expect) if err != nil { - t.Errorf(errMsg("unable to parse expected Query", err, msgAndArgs)) + t.Error(errMsg("unable to parse expected Query", err, msgAndArgs)) return false } actualQ, err := url.ParseQuery(actual) if err != nil { - t.Errorf(errMsg("unable to parse actual Query", err, msgAndArgs)) + t.Error(errMsg("unable to parse actual Query", err, msgAndArgs)) return false } @@ -106,13 +106,13 @@ func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) expectVal := map[string]interface{}{} if err := json.Unmarshal([]byte(expect), &expectVal); err != nil { - t.Errorf(errMsg("unable to parse expected JSON", err, msgAndArgs...)) + t.Error(errMsg("unable to parse expected JSON", err, msgAndArgs...)) return false } actualVal := map[string]interface{}{} if err := json.Unmarshal([]byte(actual), &actualVal); err != nil { - t.Errorf(errMsg("unable to parse actual JSON", err, msgAndArgs...)) + t.Error(errMsg("unable to parse actual JSON", err, msgAndArgs...)) return false } @@ -123,12 +123,12 @@ func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) func AssertXML(t *testing.T, expect, actual string, container interface{}, msgAndArgs ...interface{}) bool { expectVal := container if err := xml.Unmarshal([]byte(expect), &expectVal); err != nil { - t.Errorf(errMsg("unable to parse expected XML", err, msgAndArgs...)) + t.Error(errMsg("unable to parse expected XML", err, msgAndArgs...)) } actualVal := container if err := xml.Unmarshal([]byte(actual), &actualVal); err != nil { - t.Errorf(errMsg("unable to parse actual XML", err, msgAndArgs...)) + t.Error(errMsg("unable to parse actual XML", err, msgAndArgs...)) } return equal(t, expectVal, actualVal, msgAndArgs...) } diff --git a/internal/endpoints/v2/package_test.go b/internal/endpoints/v2/package_test.go index 07e02bd1500..b46c017e2aa 100644 --- a/internal/endpoints/v2/package_test.go +++ b/internal/endpoints/v2/package_test.go @@ -1303,7 +1303,7 @@ func TestLogDeprecated(t *testing.T) { Logger: log.New(buffer, "", 0), }, func(t *testing.T) { if diff := cmpDiff("WARN endpoint identifier \"bar\", url \"https://foo.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } }, @@ -1326,7 +1326,7 @@ func TestLogDeprecated(t *testing.T) { Logger: log.New(buffer, "", 0), }, func(t *testing.T) { if diff := cmpDiff("WARN endpoint identifier \"bar\", url \"https://foo-fips.bar.bar.tld\" marked as deprecated\n", buffer.String()); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } }, @@ -1352,7 +1352,7 @@ func TestLogDeprecated(t *testing.T) { } if diff := cmpDiff(tt.Expected, endpoint); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } if verifyLog != nil { diff --git a/service/kinesis/internal/testing/eventstream_test.go b/service/kinesis/internal/testing/eventstream_test.go index 8f6d4b01213..1ff6c73a13a 100644 --- a/service/kinesis/internal/testing/eventstream_test.go +++ b/service/kinesis/internal/testing/eventstream_test.go @@ -299,7 +299,7 @@ func TestSubscribeToShard_ReadException(t *testing.T) { expectedErr, &types.InternalFailureException{Message: aws.String("this is an exception message")}, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -366,7 +366,7 @@ func TestSubscribeToShard_ReadUnmodeledException(t *testing.T) { Message: "this is an unmodeled exception message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -437,7 +437,7 @@ func TestSubscribeToShard_ReadErrorEvent(t *testing.T) { Message: "An error message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -478,7 +478,7 @@ func TestSubscribeToShard_ResponseError(t *testing.T) { Message: "this is an exception message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } diff --git a/service/transcribestreaming/internal/testing/eventstream_test.go b/service/transcribestreaming/internal/testing/eventstream_test.go index aa38355401b..fcc8dbac800 100644 --- a/service/transcribestreaming/internal/testing/eventstream_test.go +++ b/service/transcribestreaming/internal/testing/eventstream_test.go @@ -270,7 +270,7 @@ func TestStartStreamTranscription_ReadException(t *testing.T) { expectedErr, &types.BadRequestException{Message: aws.String("this is an exception message")}, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -328,7 +328,7 @@ func TestStartStreamTranscription_ReadUnmodeledException(t *testing.T) { Message: "this is an unmodeled exception message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -390,7 +390,7 @@ func TestStartStreamTranscription_ReadErrorEvent(t *testing.T) { Message: "An error message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } } @@ -649,7 +649,7 @@ func TestStartStreamTranscription_ResponseError(t *testing.T) { Message: "this is an exception message", }, ); len(diff) > 0 { - t.Errorf(diff) + t.Error(diff) } }