DynamoDB — can not use both expression and non-expression parameters
TL;DR — Your request set a legacy parameter (KeyConditions, QueryFilter, ScanFilter, AttributesToGet, Expected, AttributeUpdates, ConditionalOperator) and its expression equivalent (KeyConditionExpression, FilterExpression, ProjectionExpression, ConditionExpression, UpdateExpression) in the same call. DynamoDB forbids mixing the two families. Remove the legacy parameter and use expressions only.
What it means
ValidationException: Can not use both expression and non-expression parameters in
the same request: Non-expression parameters: {KeyConditions} Expression
parameters: {KeyConditionExpression}
# what the engine actually returns, reproduced against DynamoDB Local:
ValidationException: Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {KeyConditions} Expression parameters: {KeyConditionExpression}DynamoDB has two generations of parameters. The legacy family (KeyConditions, QueryFilter, ScanFilter, AttributesToGet, Expected, AttributeUpdates, ConditionalOperator) predates expressions; the expression family (KeyConditionExpression, FilterExpression, ProjectionExpression, ConditionExpression, UpdateExpression) replaced it. A single request must commit to one family — the developer guide is explicit that DynamoDB "does not allow mixing legacy conditional parameters and expression parameters in a single call", even when they cover unrelated concerns.
Why it happens
- Half-migrated code — you added
KeyConditionExpressionbut left an oldKeyConditionson the same params object. - A projection collision —
AttributesToGet(legacy) alongsideProjectionExpression. - A filter collision —
ScanFilter/QueryFilteralongsideFilterExpression. - A write collision —
Expected/AttributeUpdatesalongsideConditionExpression/UpdateExpression. - A helper library that injects a legacy default while you set the expression form.
How to fix it
- Delete the legacy parameter. Keep only the expression form:
KeyConditionExpressionoverKeyConditions,FilterExpressionoverScanFilter/QueryFilter,ProjectionExpressionoverAttributesToGet,ConditionExpression/UpdateExpressionoverExpected/AttributeUpdates. - Move values into placeholders — legacy inline values become
ExpressionAttributeValues(:v) and reserved/complex names becomeExpressionAttributeNames(#n). - Audit the whole params object — the conflict can be between two different concerns (e.g. legacy projection + expression key condition), not just the same one.
- Prefer expressions everywhere — AWS keeps the legacy parameters only for backward compatibility and recommends the expression parameters for all new code; standardizing on expressions avoids this class of error.
- Strip legacy defaults from helper libraries. Some SDK wrappers still inject
AttributesToGetorKeyConditionsunless you explicitly disable them.
Run it in DynoTable
DynoTable's query panel uses expression parameters only — no legacy KeyConditions or ScanFilter fields exist in generated requests. Open a table with ⌘K, build a Query or Scan, and copy the emitted KeyConditionExpression and attribute maps into your migration.
Use the Query Builder to prototype the expression-only request before you refactor old SDK code. Staging (⌘S) lets you test the new query against live data without committing writes. Switch profiles with ⌘P; configure them under Settings → Profiles with Test Connection. See Connect to AWS and Install. Legacy KeyConditions and ScanFilter parameters do not appear anywhere in DynoTable-generated requests. If your SDK wrapper still injects them, log the full params object and delete every legacy key before the call reaches DynamoDB.
Sources
- Legacy DynamoDB conditional parameters (verified 2026-07-13)
- Query — Amazon DynamoDB API Reference (verified 2026-07-13)
Related errors
- Cannot specify projection when Select is COUNT — another mutually-exclusive parameter combination.
- Query key condition not supported — a malformed
KeyConditionExpression. - Code example: Query in Node.js — an expression-only Query to migrate to.
- Learn: Key condition expressions · Expression names & values
References
- Legacy DynamoDB conditional parameters — Amazon DynamoDB Developer Guide
- Query — Amazon DynamoDB API Reference
- PutItem — Amazon DynamoDB API Reference
- Using expressions in DynamoDB — Amazon DynamoDB Developer Guide
Last verified 2026-07-13 against the official AWS documentation linked above.