How to handle ConditionalCheckFailedException
See original GitHub issueMy code looks like below:
try:
cust_table.put_item(Item=company,
ConditionExpression=Attr('version').eq(previous_version))
except botocore.errorfactory.ConditionalCheckFailedException as ex:
print(ex)
I’m getting this error
# botocore.errorfactory.ConditionalCheckFailedException: An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed
# During handling of the above exception, another exception occurred:
# Traceback (most recent call last):
# File "/home/ganesh/code/vantage-trials-site-reassignment-service/createUser/src/test.py", line 45, in <module>
# except botocore.errorfactory.ConditionalCheckFailedException as ex:
# AttributeError: module 'botocore.errorfactory' has no attribute 'ConditionalCheckFailedException'
What exception to catch?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Error handling with DynamoDB - AWS Documentation
Error messages and codes · AccessDeniedException. Message: Access denied. · ConditionalCheckFailedException · IncompleteSignatureException.
Read more >[Solved] DynamoDB ConditionalCheckFailedException
Solution: Either remove ConditionExpression from your DynamoDB code or change parameters and data so the condition can be satisfied.
Read more >javascript - I am facing ConditionalCheckFailedException ...
it just means that no such key exists in database, so the conditional request is failing. – itaintme. Jul 16, 2018 at 19:03....
Read more >r/aws - Reddit
2 questions: Do you see any glaring problems handling "ConditionalCheckFailedException" errors this way? Is there a better way?
Read more >DynamoDB — botocore 1.29.25 documentation - Amazon AWS
For more information, see Batch Operations and Error Handling in the Amazon DynamoDB Developer Guide . ... ConditionalCheckFailedException; DynamoDB.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ghsatpute - You can achieve the same using the errorfactory which will create an error class based on the codes returned. This was added here
Hope this helps. We don’t have very good documentation about how to use errorfactory.
So as per my experience with programming. We catch exceptions which have been raised or their parent. For example, if a code raises
FileNotFoundException
we catchFileNotFoundException
or it’s parentIOException
if you don’t want to differentiate between types of exception.Here, the code is raising
ConditionalCheckFailedException
, I should be able to catch the same exception. Here we are catching some other exception and writing logic inside to check whether it’s a part of the exception.Obviously, this functionally works, but the working code is not everything.