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 FilterExpression to 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

  1. Only set the parameter when it's non-empty. Build the params object conditionally: if (filter) params.FilterExpression = filter; — never assign "".
  2. Delete empty keys before the call — strip any expression property whose value is an empty/whitespace string from the request.
  3. Guard your builder — if the list of conditions is empty, don't attach the expression at all.
  4. Remember they're independentExpressionAttributeNames/Values should also be omitted (not {} referenced by nothing) when there's no expression using them.
  5. For a full-table read, a Scan with no FilterExpression is 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.

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Work with DynamoDB without the Console

DynoTable is a fast desktop client for DynamoDB — browse tables, run SQL-style queries, and edit items locally.