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 Aug 18, 2023
1 parent b5b708a commit 8e45a8d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
17 changes: 17 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_0/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ apply InvalidGreeting @httpResponseTests([
}""",
bodyMediaType: "application/json",
},
{
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, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
protocol: awsJson1_0,
code: 400,
headers: {
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
},
appliesTo: "client",
},
])

/// This error is thrown when a request is invalid.
Expand Down
17 changes: 17 additions & 0 deletions smithy-aws-protocol-tests/model/awsJson1_1/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ apply InvalidGreeting @httpResponseTests([
}""",
bodyMediaType: "application/json",
},
{
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, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
protocol: awsJson1_1,
code: 400,
headers: {
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
},
appliesTo: "client",
},
])

/// This error is thrown when a request is invalid.
Expand Down
16 changes: 16 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/errors.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ apply InvalidGreeting @httpResponseTests([
}""",
bodyMediaType: "application/json",
},
{
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, 'InvalidGreeting,InvalidParameterException' is to be interpreted as 'InvalidGreeting'.""",
protocol: restJson1,
code: 400,
headers: {
"X-Amzn-Errortype": "InvalidGreeting,InvalidParameterException",
},
appliesTo: "client",
}
])

/// This error is thrown when a request is invalid.
Expand Down

0 comments on commit 8e45a8d

Please sign in to comment.