Error: Conditional Update Error DynamoDB

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
A conditional update fails with ConditionalCheckFailedException when its condition evaluates to false. DynamoDB leaves the item unchanged. This can be the intended protection against stale writes or updates to a missing item.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, UpdateCommand } from "@aws-sdk/lib-dynamodb";
const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));
await db.send(new UpdateCommand({
TableName: "Orders",
Key: { pk: "CUSTOMER#123", sk: "ORDER#42" },
UpdateExpression: "SET #status = :next",
ConditionExpression: "#status = :expected",
ExpressionAttributeNames: { "#status": "status" },
ExpressionAttributeValues: { ":next": "SHIPPED", ":expected": "PAID" },
ReturnValuesOnConditionCheckFailure: "ALL_OLD",
}));Check the complete key, attribute type and current value. Missing attributes, String versus Number differences, or another writer changing the state can explain the failure. Where supported, ALL_OLD makes the failure item available in the exception; otherwise read it and remember it can change again.
Retry only after deciding the update is still valid. A version conflict usually requires reading fresh state and recomputing the change. Removing the condition merely to make the write succeed defeats the concurrency protection.
See conditional writes and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- Dynamodb error 500
- dynamodb exclusivestartkey not working
- DynamoDB Internal Server Error
- dynamodb number_value cannot be converted to string
- dynamodb attribute does not exist
- DynamoDB sorting is not supported for scan expressions
- DynamoDB Mapper Could Not Instantiate Class
- accessdeniedexception dynamodb
- dynamodb unable to locate credentials
- dynamodb cannot read property '0' of undefined
- dynamodb: one or more parameter values were invalid: type mismatch for index key
- dynamodb-admin not working
- dynamodb cannot read properties of undefined
- DynamoDB Query Limit Not Working
- DynamoDB failedbatch retry
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today