DynamoDB — The expression can not be empty
TL;DR — You passed an expression parameter (FilterExpression, KeyConditionExpression, ProjectionExpression, UpdateExpression, or ConditionExpression) as an empty string "". DynamoDB requires expression parameters to be either a valid non-empty expression or absent entirely — an empty string is invalid. Only include the parameter when you actually have an expression; otherwise omit the key.
What it means
ValidationException: Invalid FilterExpression: The expression can not be empty;
ValidationException: Invalid KeyConditionExpression: The expression can not be empty;DynamoDB treats an empty string differently from an omitted parameter. Omitting FilterExpression means "no filter"; passing FilterExpression: "" means "here is a filter" — and then there's nothing to parse, so validation fails. The same applies to every expression parameter.
Why it happens
- Conditionally-built params always set — code always attaches
FilterExpressionto the request object, then leaves it""when no filter was chosen. - A helper/ORM/connector that emits an empty expression string instead of dropping the key when the filter list is empty.
- String concatenation that produced nothing — joining an empty array of conditions yields
"". - Trimmed-away content — placeholders were stripped, leaving an empty expression.
How to fix it
- Only set the parameter when it's non-empty. Build the params object conditionally:
if (filter) params.FilterExpression = filter;— never assign"". - Delete empty keys before the call — strip any expression property whose value is an empty/whitespace string from the request.
- Guard your builder — if the list of conditions is empty, don't attach the expression at all.
- Remember they're independent —
ExpressionAttributeNames/Valuesshould also be omitted (not{}referenced by nothing) when there's no expression using them. - For a full-table read, a
Scanwith noFilterExpressionis correct — omit the parameter rather than passing an empty one.
Prototyping queries before you wire them into code? Run them in the DynoTable desktop app — it only sends the expression parameters you actually fill in, so you won't ship an empty-string filter.
Related errors
- Query key condition not supported — a malformed (not empty)
KeyConditionExpression. - Invalid UpdateExpression syntax — a non-empty but malformed update expression.
- Learn: Filtering strategies · Key condition expressions
References
- Using expressions in DynamoDB — Amazon DynamoDB Developer Guide
- Query — Amazon DynamoDB API Reference
- Scan — Amazon DynamoDB API Reference
- Error handling with DynamoDB — Amazon DynamoDB Developer Guide
Last verified 2026-07-13 against the official AWS documentation linked above.