Error: DynamoDB Expression Not Null

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
To test whether a DynamoDB attribute has a non-null value, distinguish an absent attribute from one stored with type NULL. attribute_exists alone also matches attributes whose value is NULL.
const condition = {
ConditionExpression: "attribute_exists(#value) AND NOT attribute_type(#value, :nullType)",
ExpressionAttributeNames: { "#value": "optionalValue" },
ExpressionAttributeValues: { ":nullType": "NULL" },
};These are native values for a document-client request. With the low-level client, the type-name placeholder is { S: "NULL" }. Use FilterExpression instead of ConditionExpression when filtering query or scan results, and combine it with the operation's required key parameters.
If the actual error says an expression parameter must not be null, inspect that parameter itself: an omitted or empty expression string differs from a NULL item attribute. Every :placeholder must be defined. There is no if_exists expression function. Use attribute_exists or attribute_not_exists for tests; if_not_exists belongs in SET updates and defaults only missing attributes, not existing NULL values.
See filter syntax and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- DynamoDB Key element does not match the schema
- dynamodb could not connect to the endpoint url
- dynamodb the parameter cannot be converted to a numeric value NaN
- DynamoDB Local Cannot Create Preexisting Table
- dynamodb number_value cannot be converted to string
- dynamodb exclusivestartkey not working
- dynamodb item size limit error
- dynamodb table not exists
- DynamoDB Get not found
- ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: An AttributeValue may not contain an empty string
- moto dynamodb not working
- DynamoDB missing items
- AWS Lambda DynamoDB Stream Error
- dynamodb unknown error
- DynamoDB type is not supported
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today