Skip to content

Commit 8e45a8d

Browse files
committed
Add protocol test for handling two X-Amzn-Errortype header values
1 parent b5b708a commit 8e45a8d

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

Diff for: smithy-aws-protocol-tests/model/awsJson1_0/errors.smithy

+17
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ apply InvalidGreeting @httpResponseTests([
5858
}""",
5959
bodyMediaType: "application/json",
6060
},
61+
{
62+
id: "AwsJson10FooErrorWithMultipleAmznErrorTypes",
63+
documentation: """
64+
API Gateway always adds its own x-amzn-errortype header on gateway responses.
65+
However, this header does not match the error configured in customers model and \
66+
results in two X-Amzn-Errortype header values. \
67+
The first value is provided by the customer and the second value is from API Gateway \
68+
69+
Clients need to split the header value on ',' and take only the first element. \
70+
For example, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
71+
protocol: awsJson1_0,
72+
code: 400,
73+
headers: {
74+
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
75+
},
76+
appliesTo: "client",
77+
},
6178
])
6279

6380
/// This error is thrown when a request is invalid.

Diff for: smithy-aws-protocol-tests/model/awsJson1_1/errors.smithy

+17
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ apply InvalidGreeting @httpResponseTests([
5151
}""",
5252
bodyMediaType: "application/json",
5353
},
54+
{
55+
id: "AwsJson11FooErrorWithMultipleAmznErrorTypes",
56+
documentation: """
57+
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
58+
However, this header does not match the error configured in customers model and \
59+
results in two X-Amzn-Errortype header values. \
60+
The first value is provided by the customer and the second value is from API Gateway \
61+
62+
Clients need to split the header value on ',' and take only the first element. \
63+
For example, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
64+
protocol: awsJson1_1,
65+
code: 400,
66+
headers: {
67+
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
68+
},
69+
appliesTo: "client",
70+
},
5471
])
5572

5673
/// This error is thrown when a request is invalid.

Diff for: smithy-aws-protocol-tests/model/restJson1/errors.smithy

+16
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,23 @@ apply InvalidGreeting @httpResponseTests([
9595
}""",
9696
bodyMediaType: "application/json",
9797
},
98+
{
99+
id: "RestJsonWithMultipleAmznErrorTypes",
100+
documentation: """
101+
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
102+
However, this header does not match the error configured in customers model and \
103+
results in two X-Amzn-Errortype header values. \
104+
The first value is provided by the customer and the second value is from API Gateway \
98105
106+
Clients need to split the header value on ',' and take only the first element. \
107+
For example, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
108+
protocol: restJson1,
109+
code: 400,
110+
headers: {
111+
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
112+
},
113+
appliesTo: "client",
114+
}
99115
])
100116

101117
/// This error is thrown when a request is invalid.

0 commit comments

Comments
 (0)