Skip to content

Commit 2d8bc83

Browse files
committed
Add protocol test for handling two X-Amzn-Errortype header values
1 parent e3c94bf commit 2d8bc83

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

smithy-aws-protocol-tests/model/awsJson1_0/errors.smithy

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,22 @@ apply FooError @httpResponseTests([
261261
}""",
262262
bodyMediaType: "application/json",
263263
appliesTo: "client",
264-
}
264+
},
265+
{
266+
id: "AwsJson10FooErrorWithMultipleAmznErrorTypes",
267+
documentation: """
268+
API Gateway always adds its own x-amzn-errortype header on gateway responses.
269+
However, this header does not match the error configured in customers model and \
270+
results in two X-Amzn-Errortype header values. \
271+
The first value is provided by the customer and the second value is from API Gateway \
272+
273+
Clients need to split the header value on ',' and take only the first element. \
274+
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
275+
protocol: awsJson1_0,
276+
code: 400,
277+
headers: {
278+
"X-Amzn-Errortype": "FooError,InvalidParameterException",
279+
},
280+
appliesTo: "client",
281+
},
265282
])

smithy-aws-protocol-tests/model/awsJson1_1/errors.smithy

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,22 @@ apply FooError @httpResponseTests([
253253
}""",
254254
bodyMediaType: "application/json",
255255
appliesTo: "client",
256-
}
256+
},
257+
{
258+
id: "AwsJson11FooErrorWithMultipleAmznErrorTypes",
259+
documentation: """
260+
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
261+
However, this header does not match the error configured in customers model and \
262+
results in two X-Amzn-Errortype header values. \
263+
The first value is provided by the customer and the second value is from API Gateway \
264+
265+
Clients need to split the header value on ',' and take only the first element. \
266+
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
267+
protocol: awsJson1_1,
268+
code: 400,
269+
headers: {
270+
"X-Amzn-Errortype": "FooError,InvalidParameterException",
271+
},
272+
appliesTo: "client",
273+
},
257274
])

smithy-aws-protocol-tests/model/restJson1/errors.smithy

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ apply InvalidGreeting @httpResponseTests([
9595
}""",
9696
bodyMediaType: "application/json",
9797
},
98-
9998
])
10099

101100
/// This error is thrown when a request is invalid.
@@ -306,5 +305,22 @@ apply FooError @httpResponseTests([
306305
}""",
307306
bodyMediaType: "application/json",
308307
appliesTo: "client",
308+
},
309+
{
310+
id: "RestJsonWithMultipleAmznErrorTypes",
311+
documentation: """
312+
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
313+
However, this header does not match the error configured in customers model and \
314+
results in two X-Amzn-Errortype header values. \
315+
The first value is provided by the customer and the second value is from API Gateway \
316+
317+
Clients need to split the header value on ',' and take only the first element. \
318+
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
319+
protocol: restJson1,
320+
code: 400,
321+
headers: {
322+
"X-Amzn-Errortype": "FooError,InvalidParameterException",
323+
},
324+
appliesTo: "client",
309325
}
310326
])

0 commit comments

Comments
 (0)