Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transact_write_items doesn't return CancellationReasons when ReturnValuesOnConditionCheckFailure is set to 'ALL_OLD' #2657

Closed
brysontyrrell opened this issue Nov 9, 2020 · 3 comments
Assignees
Labels
closed-for-staleness dynamodb feature-request This issue requests a feature. p3 This is a minor priority issue

Comments

@brysontyrrell
Copy link

Describe the bug

When calling transact_write_items with any TransactItems that specify ReturnValuesOnConditionCheckFailure, and any condition check of the transaction fails, there's no values returned in the ClientError exception that is raised.

Steps to reproduce

  • Create a write transaction to a DynamoDB table with a condition check that will fail. Set ReturnValuesOnConditionCheckFailure to ALL_OLD.
  • Specify to return ALL_OLD on condition check failures.
  • Run the transaction so the condition check fails.

Expected behavior

DynamoDB client raises TransactionCanceledException and the CancellationReasons are provided as a part of the error object.

Debug logs
Full stack trace by adding boto3.set_stream_logger('') to your code.

(redacting some of this)

b'{"__type":"com.amazonaws.dynamodb.v20120810#TransactionCanceledException","CancellationReasons":[{"Code":"None"},{"Code":"ConditionalCheckFailed","Item":{"sk":{"S":"**********"},"gsi1sk":{"S":"**********"},"pk":{"S":"**********"},"gsi1pk":{"S":"**********"},"type":{"S":"**********"}},"Message":"The conditional request failed"}],"Message":"Transaction cancelled, please refer cancellation reasons for specific reasons [None, ConditionalCheckFailed]"}'

Found #1990 which originally reported this.

The Java SDK seems to have implemented returning CancellationReasons.

Tagging @bradschm

@swetashre
Copy link
Contributor

@brysontyrrell - Thank you for your post. According to the documentation

If using Java, DynamoDB lists the cancellation reasons on the CancellationReasons property. This property is not set for other languages.

This explains the behavior you are seeing. Marking this as feature request for supporting it with python.

@swetashre swetashre added feature-request This issue requests a feature. dynamodb and removed needs-triage This issue or PR still needs to be triaged. labels Nov 11, 2020
@swetashre swetashre assigned kdaily and unassigned swetashre Mar 25, 2021
@brysontyrrell
Copy link
Author

👋 it looks like this has been implemented? I have CacellationReasons in the error response now (was writing a sample for someone else and saw it there):

{
    "Error": {
        "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed, None]",
        "Code": "TransactionCanceledException"
    },
    "ResponseMetadata": {
        "RequestId": "XXXXX",
        "HTTPStatusCode": 400,
        "HTTPHeaders": {
            "server": "Server",
            "date": "Tue, 22 Feb 2022 20:19:37 GMT",
            "content-type": "application/x-amz-json-1.0",
            "content-length": "312",
            "connection": "keep-alive",
            "x-amzn-requestid": "XXXXX",
            "x-amz-crc32": "XXXXX"
        },
        "RetryAttempts": 0
    },
    "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed, None]",
    "CancellationReasons": [
        {
            "Code": "ConditionalCheckFailed",
            "Message": "The conditional request failed"
        },
        {
            "Code": "None"
        }
    ]
}

@aBurmeseDev
Copy link
Contributor

Just checking in here as it looks like the CacellationReasons has been implemented to be in the error response. Thank you @brysontyrrell for following up, I was able to confirm it on my end as well. I'm going to close this issue now and please reach out to us again if you have any other questions!

@aBurmeseDev aBurmeseDev added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 3, 2022
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 5, 2022
@github-actions github-actions bot closed this as completed Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness dynamodb feature-request This issue requests a feature. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

4 participants