Error: DynamoDB Is Not Null

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
DynamoDB does not have a general SQL-style NOT NULL column constraint. Table primary keys must contain valid scalar values, while ordinary attributes may be absent or explicitly NULL. An optional secondary-index key can be omitted, but cannot be NULL when present.
For a native document-client filter that selects an existing non-null ordinary attribute, use:
const filter = {
FilterExpression: "attribute_exists(#value) AND NOT attribute_type(#value, :nullType)",
ExpressionAttributeNames: { "#value": "optionalValue" },
ExpressionAttributeValues: { ":nullType": "NULL" },
};Merge these fields into a valid Query or Scan request. attribute_exists alone also matches NULL. Empty strings and empty lists are values and pass this non-null check; validate them separately if your application forbids them.
For keys, supply the declared String, Number or Binary type. You cannot change a primary-key schema to allow NULL. Remove an optional GSI key attribute to exclude the item from that sparse index. Use ConditionExpression to enforce a rule atomically on a write rather than relying on a separate pre-read.
See missing and NULL values and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- DynamoDB No Regionendpoint Or Serviceurl Configured
- DynamoDB could not invoke null on class
- DynamoDB failedbatch retry
- dynamodb table not exists
- KMS Key Access Denied Error DynamoDB
- dynamodb cannot read property '0' of undefined
- dynamodb item size limit error
- accessdeniedexception dynamodb
- DynamoDB stream no records processed
- dynamodb throughput error
- dynamodb table did not stabilize
- dynamodb mapper save not persisting
- DynamoDB type is not supported
- AWS DynamoDB errors ResourceNotFoundException
- Error retrieving DynamoDB table item validation exception
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today