Skip to content

Commit a38059c

Browse files
authored
Updates the error code returned for Errors modeled with awsQueryError trait (#1333)
* java codegen change to override getErrorCode method for awsQuery protocol and use AwsQueryError trait * generated clients and protocol test to use awsQueryError trait * remove hard coded error code from web identity provider test
1 parent 0806248 commit a38059c

File tree

20 files changed

+459
-601
lines changed

20 files changed

+459
-601
lines changed

codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/AwsQuery.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import software.amazon.smithy.model.shapes.Shape;
2525
import software.amazon.smithy.model.shapes.ShapeId;
2626
import software.amazon.smithy.model.shapes.StructureShape;
27+
import software.amazon.smithy.model.traits.ErrorTrait;
2728

2829
/**
2930
* Handles generating the aws query protocol for services.
@@ -174,4 +175,14 @@ public Map<String, ShapeId> getOperationErrors(GenerationContext context, Operat
174175

175176
return errors;
176177
}
178+
179+
@Override
180+
public String getErrorCode(ServiceShape service, StructureShape errorShape) {
181+
Optional<AwsQueryErrorTrait> trait = errorShape.getTrait(AwsQueryErrorTrait.class);
182+
if (trait.isPresent()) {
183+
return trait.get().getCode();
184+
}
185+
186+
return super.getErrorCode(service, errorShape);
187+
}
177188
}

credentials/stscreds/web_identity_provider_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ func TestWebIdentityProviderRetrieve(t *testing.T) {
8585
fn(&o)
8686
}
8787

88-
if o.Retryer.IsErrorRetryable(mockErrorCode("InvalidIdentityTokenException")) != true {
89-
return nil, fmt.Errorf("expected InvalidIdentityTokenException to be retryable")
88+
errorCode := (&types.InvalidIdentityTokenException{}).ErrorCode()
89+
if o.Retryer.IsErrorRetryable(mockErrorCode(errorCode)) != true {
90+
return nil, fmt.Errorf("expected %v to be retryable", errorCode)
9091
}
9192

9293
return &sts.AssumeRoleWithWebIdentityOutput{

internal/protocoltest/query/types/errors.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/autoscaling/types/errors.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/cloudformation/types/errors.go

Lines changed: 4 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/cloudsearch/types/errors.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/cloudwatch/types/errors.go

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)