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.
Run it in DynoTable
DynoTable only sends expression parameters you actually configure — an empty filter list omits FilterExpression entirely instead of passing "". Open a table with ⌘K, add filters in the query panel, and copy the generated request when at least one condition is present.
Use the Query Builder to prototype reads before wiring conditional params in code. Staging (⌘S) catches empty-expression mistakes on updates. Switch profiles with ⌘P; Test Connection on Settings → Profiles confirms the target table. See Connect to AWS and Install. An omitted parameter and an empty string are different — only the latter triggers this error.
Sources
- Using expressions in DynamoDB (verified 2026-07-13)
- Query — Amazon DynamoDB API Reference (verified 2026-07-13)
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.