From 7be1336444e91daf7a4d27419910a9ca0518230d Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:34:45 -0500 Subject: [PATCH] fix: correct error wrapping in auth codegen (#484) --- .../go/codegen/auth/GetIdentityMiddlewareGenerator.java | 2 +- .../go/codegen/auth/ResolveAuthSchemeMiddlewareGenerator.java | 4 ++-- .../go/codegen/auth/SignRequestMiddlewareGenerator.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/GetIdentityMiddlewareGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/GetIdentityMiddlewareGenerator.java index 643743b42..bed1cf774 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/GetIdentityMiddlewareGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/GetIdentityMiddlewareGenerator.java @@ -76,7 +76,7 @@ private GoWriter.Writable generateBody() { identity, err := resolver.GetIdentity(ctx, rscheme.IdentityProperties) if err != nil { - return out, metadata, $errorf:T("get identity: %v", err) + return out, metadata, $errorf:T("get identity: %w", err) } ctx = setIdentity(ctx, identity) diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/ResolveAuthSchemeMiddlewareGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/ResolveAuthSchemeMiddlewareGenerator.java index bf45ae315..b8eeca564 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/ResolveAuthSchemeMiddlewareGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/ResolveAuthSchemeMiddlewareGenerator.java @@ -39,7 +39,7 @@ public ResolveAuthSchemeMiddlewareGenerator(ProtocolGenerator.GenerationContext public static GoWriter.Writable generateAddToProtocolFinalizers() { return goTemplate(""" if err := stack.Finalize.Add(&$L{operation: operation, options: options}, $T); err != nil { - return $T("add $L: %v", err) + return $T("add $L: %w", err) } """, MIDDLEWARE_NAME, @@ -69,7 +69,7 @@ private GoWriter.Writable generateBody() { params := $1L(m.operation, getOperationInput(ctx), m.options) options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params) if err != nil { - return out, metadata, $2T("resolve auth scheme: %v", err) + return out, metadata, $2T("resolve auth scheme: %w", err) } scheme, ok := m.selectScheme(options) diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/SignRequestMiddlewareGenerator.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/SignRequestMiddlewareGenerator.java index 0fac9fa7a..50a72e5fc 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/SignRequestMiddlewareGenerator.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/auth/SignRequestMiddlewareGenerator.java @@ -40,7 +40,7 @@ public SignRequestMiddlewareGenerator(ProtocolGenerator.GenerationContext contex public static GoWriter.Writable generateAddToProtocolFinalizers() { return goTemplate(""" if err := stack.Finalize.Insert(&$L{}, $S, $T); err != nil { - return $T("add $L: %v", err) + return $T("add $L: %w", err) } """, MIDDLEWARE_NAME, @@ -82,7 +82,7 @@ private GoWriter.Writable generateBody() { } if err := signer.SignRequest(ctx, req, identity, rscheme.SignerProperties); err != nil { - return out, metadata, $errorf:T("sign request: %v", err) + return out, metadata, $errorf:T("sign request: %w", err) } return next.HandleFinalize(ctx, in)