Error: dynamodb condition does not exist

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
To test that an item or attribute does not exist, use attribute_not_exists in a DynamoDB expression. “Condition does not exist” is not a distinct DynamoDB service exception. A valid write condition that evaluates to false produces ConditionalCheckFailedException.
For a create-only put, test the partition-key attribute. DynamoDB evaluates the condition against the item at the full primary key, including the sort key when present:
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
const db = DynamoDBDocumentClient.from(new DynamoDBClient({ region: "us-east-1" }));
await db.send(new PutCommand({
TableName: "Orders",
Item: { pk: "ORDER#123", sk: "DETAIL" },
ConditionExpression: "attribute_not_exists(#pk)",
ExpressionAttributeNames: { "#pk": "pk" }
}));To find records missing a non-key attribute, use attribute_not_exists(#field) in a Query or Scan filter instead. An attribute stored as DynamoDB NULL still exists; missing and null are different states. If a write condition fails, inspect the current item and decide whether to reject or recompute the operation. Removing the condition can overwrite data the application intended to protect.
See conditional writes and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- DynamoDB failedbatch retry
- DynamoDB Failed To Compute Node presentation
- DynamoDB string set cannot be empty
- DynamoDB Scan Not Working
- failed to list tables not authorized dynamodb
- dynamodb global secondary index does not project
- ConfigError: Missing region in config
- a bytes-like object is required not binary dynamodb
- dynamodb is abstract cannot be instantiated
- dynamodb could not connect to the endpoint url
- DynamoDB scan does not return all items
- dynamodb cannot read property 'push' of undefined
- DynamoDB Not Supported Requires @DynamoDBTyped Or @DynamoDBTypeConverted
- dynamodb no range key value present
- DynamoDB Local Docker Not Working
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable