Describe the bug
dynamodb_client.transact_write_items now returns "CancellationReasons" in the error response.
Attempting to write a test around this is not possible with the Stubber.
Here is the error response for a conditional check failure using a transaction with boto3:
{
"Error": {
"Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]",
"Code": "TransactionCanceledException"
},
"ResponseMetadata": {...},
"Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]",
"CancellationReasons": [
{
"Code": "ConditionalCheckFailed",
"Message": "The conditional request failed"
}
]
}
CancellationReasons is a top level key instead of residing inside of the Error (also, strangely, Message is duplicated here as well).
The Stubber only allows adding metadata to the error or response. Both examples of these Stubber generated outputs are shown below (captured during pytest runs).
stubber.add_client_error(
"transact_write_items",
service_error_code="TransactionCanceledException",
service_message="Transaction cancelled, please refer cancellation reasons for specific reasons [None, ConditionalCheckFailed]",
response_meta={"CancellationReasons": [{"Code": "ConditionalCheckFailed"}]},
# service_error_meta={...},
http_status_code=400,
expected_params=expected_params,
)
{
"ResponseMetadata": {
"HTTPStatusCode": 400,
"CancellationReasons": [
{
"Code": "ConditionalCheckFailed"
}
]
},
"Error": {
"Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]",
"Code": "TransactionCanceledException"
}
}
{
"ResponseMetadata": {
"HTTPStatusCode": 400
},
"Error": {
"Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]",
"Code": "TransactionCanceledException",
"CancellationReasons": [
{
"Code": "ConditionalCheckFailed"
}
]
}
}
Expected behavior
This is the only operation in boto3 I've come across that breaks with the Stubber.
It is not clear to me if the Stubber needs to be updated to accomondate how transact_write_items returns "CancellationReasons", or if the implementation of returning "CancellationReasons" has a bug and those keys are supposed to be inside the Error.
Describe the bug
dynamodb_client.transact_write_itemsnow returns "CancellationReasons" in the error response.Attempting to write a test around this is not possible with the Stubber.
Here is the error response for a conditional check failure using a transaction with boto3:
{ "Error": { "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]", "Code": "TransactionCanceledException" }, "ResponseMetadata": {...}, "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]", "CancellationReasons": [ { "Code": "ConditionalCheckFailed", "Message": "The conditional request failed" } ] }CancellationReasonsis a top level key instead of residing inside of theError(also, strangely,Messageis duplicated here as well).The Stubber only allows adding metadata to the error or response. Both examples of these Stubber generated outputs are shown below (captured during pytest runs).
{ "ResponseMetadata": { "HTTPStatusCode": 400, "CancellationReasons": [ { "Code": "ConditionalCheckFailed" } ] }, "Error": { "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]", "Code": "TransactionCanceledException" } }{ "ResponseMetadata": { "HTTPStatusCode": 400 }, "Error": { "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]", "Code": "TransactionCanceledException", "CancellationReasons": [ { "Code": "ConditionalCheckFailed" } ] } }Expected behavior
This is the only operation in
boto3I've come across that breaks with the Stubber.It is not clear to me if the Stubber needs to be updated to accomondate how
transact_write_itemsreturns "CancellationReasons", or if the implementation of returning "CancellationReasons" has a bug and those keys are supposed to be inside theError.