aws-sdk-go-v2
aws-sdk-go-v2 copied to clipboard
Setting Step Function's Client Retryer nil returns segmentation fault for StartExecution API
Describe the bug
The SDK Client is set up as below:
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/sfn"
)
func newStepFunction() AwsStepFunctionClient {
sfnClientConfig, _ := config.LoadDefaultConfig(context.Background(), func(options *config.LoadOptions) error {
options.Region = "Region"
options.Credentials = getStepFunctionCredProvider(awsConfig)
return nil
})
var opts []func(*sfn.Options)
opts = append(opts, func(o *sfn.Options) {
o.Retryer = nil
})
return sfn.NewFromConfig(sfnClientConfig, opts...)
}
func getStepFunctionCredProvider() aws.CredentialsProviderFunc {
return func(context.Context) (aws.Credentials, error) {
return aws.Credentials{
AccessKeyID: "AccessKeyId",
SecretAccessKey: "SecretAccessKey",
}, nil
}
}
The client gets created successfully. But upon calling the StartExecution API, the process panics.
Expected Behavior
The process should not panic; it should successfully start the execution. Also, in the event of any error, the process should not be retried.
Current Behavior
Currently, the process returns segmentation fault. I am pasting the stack trace below:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x16336f2]
goroutine 125 [running]:
github.com/aws/aws-sdk-go-v2/aws/retry.(*wrappedAsRetryerV2).MaxAttempts(0xc000121390, 0xc00058f7a0)
<autogenerated>:1 +0x32
github.com/aws/aws-sdk-go-v2/aws/retry.(*Attempt).HandleFinalize(0xc0006505e0, 0x1e3eee0, 0xc0006e50b0, 0x1cc24c0, 0xc0006e5020, 0x1e1d820, 0xc000650880, 0xc0006508a0, 0xc0001a1668, 0x0, ...)
github.com/aws/[email protected]/aws/retry/middleware.go:73 +0x58
github.com/aws/smithy-go/middleware.decoratedFinalizeHandler.HandleFinalize(...)
github.com/aws/[email protected]/middleware/step_finalize.go:200
github.com/aws/smithy-go/middleware.(*FinalizeStep).HandleMiddleware(0xc00064e3c0, 0x1e3eee0, 0xc0006e50b0, 0x1cc24c0, 0xc0006e5020, 0x1e1d840, 0xc000650660, 0xc0001a17f0, 0x24651c0, 0x203000, ...)
github.com/aws/[email protected]/middleware/step_finalize.go:114 +0x1b7
github.com/aws/smithy-go/middleware.decoratedHandler.Handle(...)
github.com/aws/[email protected]/middleware/middleware.go:57
github.com/aws/smithy-go/middleware.buildWrapHandler.HandleBuild(...)
github.com/aws/[email protected]/middleware/step_build.go:184
github.com/aws/aws-sdk-go-v2/aws/middleware.(*requestUserAgent).HandleBuild(0xc0001213a0, 0x1e3eee0, 0xc0006e50b0, 0x1cc24c0, 0xc0006e5020, 0x1e1d7c0, 0xc000121440, 0x2495748, 0x1baa100, 0xc0006e5080, ...)
github.com/aws/[email protected]/aws/middleware/user_agent.go:217 +0x231
github.com/aws/smithy-go/middleware.decoratedBuildHandler.HandleBuild(...)
github.com/aws/[email protected]/middleware/step_build.go:200
github.com/aws/aws-sdk-go-v2/aws/signer/v4.(*computePayloadSHA256).HandleBuild(0x2495748, 0x1e3eee0, 0xc0006e4f60, 0x1cc24c0, 0xc0006e5020, 0x1e1d7e0, 0xc0006507e0, 0xc0006e4ff0, 0xc0001a1a01, 0x100fbf0, ...)
github.com/aws/[email protected]/aws/signer/v4/middleware.go:200 +0x27c
github.com/aws/smithy-go/middleware.decoratedBuildHandler.HandleBuild(...)
github.com/aws/[email protected]/middleware/step_build.go:200
github.com/aws/smithy-go/transport/http.(*ComputeContentLength).HandleBuild(0x2495748, 0x1e3eee0, 0xc0006e4f60, 0x1cc24c0, 0xc0006e5020, 0x1e1d7e0, 0xc000650800, 0xacf6613e1471082, 0xc0001cedc0, 0x844829c491c09f5c, ...)
github.com/aws/[email protected]/transport/http/middleware_content_length.go:49 +0x197
github.com/aws/smithy-go/middleware.decoratedBuildHandler.HandleBuild(...)
github.com/aws/[email protected]/middleware/step_build.go:200
github.com/aws/aws-sdk-go-v2/aws/middleware.ClientRequestID.HandleBuild(0x1e3eee0, 0xc0006e4f60, 0x1cc24c0, 0xc0006e5020, 0x1e1d7e0, 0xc000650820, 0x20, 0x20, 0x273b7d0, 0xc000650840, ...)
github.com/aws/[email protected]/aws/middleware/middleware.go:42 +0x1ed
github.com/aws/smithy-go/middleware.decoratedBuildHandler.HandleBuild(...)
github.com/aws/[email protected]/middleware/step_build.go:200
github.com/aws/smithy-go/middleware.(*BuildStep).HandleMiddleware(0xc00064e3b8, 0x1e3eee0, 0xc0006e4f60, 0x1cc24c0, 0xc0006e5020, 0x1e1d840, 0xc000650680, 0x1c3c1c0, 0xc0006e4fc0, 0x1ce434f, ...)
github.com/aws/[email protected]/middleware/step_build.go:114 +0x1b7
github.com/aws/smithy-go/middleware.decoratedHandler.Handle(...)
github.com/aws/[email protected]/middleware/middleware.go:57
github.com/aws/smithy-go/middleware.serializeWrapHandler.HandleSerialize(...)
github.com/aws/[email protected]/middleware/step_serialize.go:192
github.com/aws/aws-sdk-go-v2/service/sfn.(*awsAwsjson10_serializeOpStartExecution).HandleSerialize(0x2495748, 0x1e3eee0, 0xc0006e4f60, 0x1b6f0c0, 0xc0006e4990, 0x1cc24c0, 0xc0006e4db0, 0x1e1d900, 0xc000121410, 0x2495748, ...)
github.com/aws/aws-sdk-go-v2/service/[email protected]/serializers.go:1005 +0x7af
github.com/aws/smithy-go/middleware.decoratedSerializeHandler.HandleSerialize(...)
github.com/aws/[email protected]/middleware/step_serialize.go:208
github.com/aws/aws-sdk-go-v2/service/sfn.(*ResolveEndpoint).HandleSerialize(0xc0006674f0, 0x1e3eee0, 0xc0006e4d80, 0x1b6f0c0, 0xc0006e4990, 0x1cc24c0, 0xc0006e4db0, 0x1e1d880, 0xc000650780, 0x1626aa5, ...)
github.com/aws/aws-sdk-go-v2/service/[email protected]/endpoints.go:116 +0x6fb
github.com/aws/smithy-go/middleware.decoratedSerializeHandler.HandleSerialize(...)
github.com/aws/[email protected]/middleware/step_serialize.go:208
github.com/aws/smithy-go/middleware.(*SerializeStep).HandleMiddleware(0xc000121340, 0x1e3eee0, 0xc0006e4d80, 0x1b6f0c0, 0xc0006e4990, 0x1e1d840, 0xc0006506a0, 0x1050b45, 0xc00004a800, 0x203000, ...)
github.com/aws/[email protected]/middleware/step_serialize.go:122 +0x1fb
github.com/aws/smithy-go/middleware.decoratedHandler.Handle(...)
github.com/aws/[email protected]/middleware/middleware.go:57
github.com/aws/smithy-go/middleware.initializeWrapHandler.HandleInitialize(...)
github.com/aws/[email protected]/middleware/step_initialize.go:184
github.com/aws/aws-sdk-go-v2/service/sfn.(*validateOpStartExecution).HandleInitialize(0x2495748, 0x1e3eee0, 0xc0006e4d80, 0x1b6f0c0, 0xc0006e4990, 0x1e1d8e0, 0xc0001213c0, 0x1114d86, 0x1c55a60, 0xc0006e4d80, ...)
github.com/aws/aws-sdk-go-v2/service/[email protected]/validators.go:329 +0xdb
github.com/aws/smithy-go/middleware.decoratedInitializeHandler.HandleInitialize(...)
github.com/aws/[email protected]/middleware/step_initialize.go:200
github.com/aws/smithy-go/middleware.(*setLogger).HandleInitialize(0xc000121380, 0x1e3eee0, 0xc0006e4d50, 0x1b6f0c0, 0xc0006e4990, 0x1e1d860, 0xc000650700, 0x2495748, 0x1baa100, 0xc0006e4d20, ...)
github.com/aws/[email protected]/middleware/logging.go:45 +0xb5
github.com/aws/smithy-go/middleware.decoratedInitializeHandler.HandleInitialize(...)
github.com/aws/[email protected]/middleware/step_initialize.go:200
github.com/aws/aws-sdk-go-v2/aws/middleware.RegisterServiceMetadata.HandleInitialize(0x1cdaf0a, 0x3, 0x1cddad5, 0x6, 0x1ce4881, 0xe, 0x1ce473f, 0xe, 0x1e3eee0, 0xc0006e4a50, ...)
github.com/aws/[email protected]/aws/middleware/metadata.go:40 +0xe7
github.com/aws/smithy-go/middleware.decoratedInitializeHandler.HandleInitialize(...)
github.com/aws/[email protected]/middleware/step_initialize.go:200
github.com/aws/smithy-go/middleware.(*InitializeStep).HandleMiddleware(0xc00064e3b0, 0x1e3eee0, 0xc0006e4a50, 0x1b6f0c0, 0xc0006e4990, 0x1e1d840, 0xc0006506c0, 0x0, 0x1e1d840, 0xc0006506c0, ...)
github.com/aws/[email protected]/middleware/step_initialize.go:114 +0x1b7
github.com/aws/smithy-go/middleware.decoratedHandler.Handle(...)
github.com/aws/[email protected]/middleware/middleware.go:57
github.com/aws/smithy-go/middleware.(*Stack).HandleMiddleware(0xc000672c80, 0x1e3eee0, 0xc0006e4a50, 0x1b6f0c0, 0xc0006e4990, 0x1e1d920, 0xc0001213b0, 0x0, 0x1e1d920, 0xc0001213b0, ...)
github.com/aws/[email protected]/middleware/stack.go:109 +0x151
github.com/aws/smithy-go/middleware.decoratedHandler.Handle(...)
github.com/aws/[email protected]/middleware/middleware.go:57
github.com/aws/aws-sdk-go-v2/service/sfn.(*Client).invokeOperation(0xc00012fa40, 0x1e3eee0, 0xc0002a2720, 0x1ce473f, 0xe, 0x1b6f0c0, 0xc0006e4990, 0x0, 0x0, 0x0, ...)
github.com/aws/aws-sdk-go-v2/service/[email protected]/api_client.go:186 +0x625
github.com/aws/aws-sdk-go-v2/service/sfn.(*Client).StartExecution(0xc00012fa40, 0x1e3eee0, 0xc0002a2720, 0xc0006e4990, 0x0, 0x0, 0x0, 0x2, 0x6, 0x203000)
github.com/aws/aws-sdk-go-v2/service/[email protected]/api_op_StartExecution.go:24 +0x11e
Reproduction Steps
Please use the created client as described in the first section to call StartExecution API on any state machine.
Possible Solution
No response
Additional Information/Context
While I understand that having retries is good to have, probably must. But I was working on something which needed limited or no retries, and came across this.
I can also go with my own implementation of the Retryer interface to obtain a limited or no retry retrier. But perhaps writing that implementation feels a bit tedious when I actually want no retries at all.
Since nil was also a valid value to provide to the Retryer in the Options, I first went with that and found this issue.
(On a side note, the aws-sdk-go-v1 does not even provide an option to set the Retryer as nil. It always creates a default retryer and attaches to the config.)
AWS Go SDK version used
github.com/aws/aws-sdk-go-v2 v1.16.2; github.com/aws/aws-sdk-go-v2/config v1.15.3; github.com/aws/aws-sdk-go-v2/service/sfn v1.13.3
Compiler and Version used
go version go1.15.15 darwin/amd64
Operating System and version
macOS Catalina Version 10.15.7 (19H2)
Hi @abhinavsingh-swiggy thanks for reaching out. Do you have the full code of how you use StartExecution API? I have some similar code with Retryer but it is not reproducing the same behavior as you mentioned above.
const profile, region = "default", "us-west-2"
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx,
config.WithRegion(region),
config.WithSharedConfigProfile(profile),
config.WithRetryer(func() aws.Retryer {
return retry.AddWithMaxAttempts(retry.NewStandard(), 5)
}),
)
if err != nil {
return fmt.Errorf("failed to load aws credentials: %w", err)
}
caller, err := sts.NewFromConfig(cfg).
GetCallerIdentity(ctx, new(sts.GetCallerIdentityInput))
if err != nil {
return fmt.Errorf("failed to retrieve caller identity: %w", err)
}
fmt.Println("CALLER:", aws.ToString(caller.Arn))
Please confirm again if this is persisting with the latest version of SDK also.
Hi @vudh1 the behaviour is seen with a nil retryer for any API. In your code, you have a non-nil retryer. Also: retryer must be set to nil not in the function options for creating the config, but the function options for creating the client.
Refer the code I have written in the Description, and use it to create your client.
Retryer is a required config - the intended way to disable retries is via aws.NopRetryer.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.