Expression size has exceeded the maximum allowed size
TL;DR — DynamoDB limits any single expression string to 4 KB (the UpdateExpression, ConditionExpression, FilterExpression, KeyConditionExpression, or ProjectionExpression). Yours grew past it — usually an auto-generated update over a big item, or a giant IN (…) / OR filter. Shrink the expression, not the item.
What it means
ValidationException: Expression size has exceeded the maximum allowed size
Invalid ConditionExpression: Expression size has exceeded the maximum allowed sizeThe 4 KB cap is on the length of the expression string itself, independent of the item's 400 KB size. A well-under-400 KB item can still overflow the expression budget if the SDK builds one clause per attribute (verbose placeholder names add up fast). It's an HTTP 400 ValidationException — not retryable without changing the expression.
Why it happens
- Auto-generated
UpdateExpressionover a wide item — an ORM/mapper emitsSET #a0 = :v0, #a1 = :v1, …for every attribute, and the placeholder names + separators cross 4 KB. - A huge
FilterExpression— a longattr IN (:0, :1, …)or a chain ofORed conditions. - Bulk conditional writes with many
attribute_not_exists/comparisons in oneConditionExpression. - Console edits of large items — saving a big item re-emits a large update/condition expression.
How to fix it
- Only update what changed. Build the
UpdateExpressionfrom the diff, not the whole item — most updates touch a handful of attributes. - Shorten placeholder names.
#a/:vbeat long descriptive names; the length that counts is the expression string, so terser names buy real headroom. - Split a giant filter into narrower queries, or restructure so the filter isn't needed (a better key/index means fewer
ORed conditions). - Break one oversized write into several smaller updates, or model the item so a single logical change doesn't rewrite everything.
- Reduce nesting — deeply nested map paths inflate expression length; flatten where you can.
Watching item and update size together? The DynoTable desktop app surfaces the attributes on each item so it's obvious when an update would touch far more than it needs to.
Related errors
- Item size exceeded the maximum (400 KB) — the item, not the expression, is too big.
- Reserved keyword in attribute name — why you needed placeholders in the first place.
- Learn: Update expressions · Filtering strategies