Skip to content

Commit

Permalink
Add protocol test for handling two X-Amzn-Errortype header values
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFossAWS committed Sep 21, 2023
1 parent e3c94bf commit 2d8bc83
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
19 changes: 18 additions & 1 deletion smithy-aws-protocol-tests/model/awsJson1_0/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,22 @@ apply FooError @httpResponseTests([
}""",
bodyMediaType: "application/json",
appliesTo: "client",
}
},
{
id: "AwsJson10FooErrorWithMultipleAmznErrorTypes",
documentation: """
API Gateway always adds its own x-amzn-errortype header on gateway responses.
However, this header does not match the error configured in customers model and \
results in two X-Amzn-Errortype header values. \
The first value is provided by the customer and the second value is from API Gateway \
Clients need to split the header value on ',' and take only the first element. \
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
protocol: awsJson1_0,
code: 400,
headers: {
"X-Amzn-Errortype": "FooError,InvalidParameterException",
},
appliesTo: "client",
},
])
19 changes: 18 additions & 1 deletion smithy-aws-protocol-tests/model/awsJson1_1/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,22 @@ apply FooError @httpResponseTests([
}""",
bodyMediaType: "application/json",
appliesTo: "client",
}
},
{
id: "AwsJson11FooErrorWithMultipleAmznErrorTypes",
documentation: """
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
However, this header does not match the error configured in customers model and \
results in two X-Amzn-Errortype header values. \
The first value is provided by the customer and the second value is from API Gateway \
Clients need to split the header value on ',' and take only the first element. \
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
protocol: awsJson1_1,
code: 400,
headers: {
"X-Amzn-Errortype": "FooError,InvalidParameterException",
},
appliesTo: "client",
},
])
18 changes: 17 additions & 1 deletion smithy-aws-protocol-tests/model/restJson1/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ apply InvalidGreeting @httpResponseTests([
}""",
bodyMediaType: "application/json",
},

])

/// This error is thrown when a request is invalid.
Expand Down Expand Up @@ -306,5 +305,22 @@ apply FooError @httpResponseTests([
}""",
bodyMediaType: "application/json",
appliesTo: "client",
},
{
id: "RestJsonWithMultipleAmznErrorTypes",
documentation: """
API-Gateway always adds its own x-amzn-errortype header on gateway responses.
However, this header does not match the error configured in customers model and \
results in two X-Amzn-Errortype header values. \
The first value is provided by the customer and the second value is from API Gateway \
Clients need to split the header value on ',' and take only the first element. \
For example, 'FooError,InvalidParameterException' is to be interpreted as 'FooError'.""",
protocol: restJson1,
code: 400,
headers: {
"X-Amzn-Errortype": "FooError,InvalidParameterException",
},
appliesTo: "client",
}
])

0 comments on commit 2d8bc83

Please sign in to comment.