Skip to content

Commit 3953a0d

Browse files
authored
add explicit message deser to all s3 errors (#3237)
1 parent e7eec69 commit 3953a0d

File tree

4 files changed

+632
-45
lines changed

4 files changed

+632
-45
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "e31d3319-2a6d-40c8-a4bb-f75347e17435",
3+
"type": "bugfix",
4+
"description": "Fix missing error message when service returns a specific type of error.",
5+
"modules": [
6+
"service/s3"
7+
]
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package software.amazon.smithy.aws.go.codegen.customization.service.s3;
2+
3+
import software.amazon.smithy.go.codegen.GoSettings;
4+
import software.amazon.smithy.go.codegen.integration.GoIntegration;
5+
import software.amazon.smithy.model.Model;
6+
import software.amazon.smithy.model.shapes.Shape;
7+
import software.amazon.smithy.model.shapes.ShapeId;
8+
import software.amazon.smithy.model.shapes.StructureShape;
9+
import software.amazon.smithy.model.traits.ErrorTrait;
10+
import software.amazon.smithy.model.transform.ModelTransformer;
11+
12+
public class S3AddErrorMessage implements GoIntegration {
13+
@Override
14+
public Model preprocessModel(Model model, GoSettings settings) {
15+
if (!S3ModelUtils.isServiceS3(model, settings.getService(model))) {
16+
return model;
17+
}
18+
19+
return ModelTransformer.create()
20+
.mapShapes(model, (shape) ->
21+
shape.hasTrait(ErrorTrait.class)
22+
? withMessage(shape)
23+
: shape
24+
);
25+
}
26+
27+
private static Shape withMessage(Shape shape) {
28+
return ((StructureShape) shape).toBuilder()
29+
.addMember("Message", ShapeId.from("com.amazonaws.s3#Message"))
30+
.build();
31+
}
32+
}

codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ software.amazon.smithy.aws.go.codegen.customization.SraOperationOrderTest
9393
software.amazon.smithy.aws.go.codegen.customization.RemoveOperations
9494
software.amazon.smithy.aws.go.codegen.customization.RetryInterceptors
9595
software.amazon.smithy.aws.go.codegen.customization.service.BearerTokenEnvProvider
96+
software.amazon.smithy.aws.go.codegen.customization.service.s3.S3AddErrorMessage

0 commit comments

Comments
 (0)