Error: dynamodb query is null

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
A DynamoDB Query with no matches returns an empty result set, not a null query object. If you want to find null-valued attributes, test the DynamoDB NULL type. If you want missing attributes, use attribute_not_exists; those are different conditions.
import boto3
from boto3.dynamodb.conditions import Key, Attr
table = boto3.resource("dynamodb", region_name="us-east-1").Table("Orders")
page = table.query(
KeyConditionExpression=Key("pk").eq("CUSTOMER#123"),
FilterExpression=Attr("note").attribute_type("NULL"),
)
items = page.get("Items", [])
# For absent attributes instead, use Attr("note").not_exists().To include either missing or NULL values, combine Attr("note").not_exists() | Attr("note").attribute_type("NULL"). Continue pagination while LastEvaluatedKey is present; a filtered page can be empty before the query is finished.
If your application receives null or undefined rather than a normal response, check that it awaited and returned the SDK call and did not swallow an exception. A missing TableName or an invalid key condition produces a validation error, not the normal empty-result case.
See boto3 Query examples and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- dynamodb validation error detected
- Error ValidationException: One or more parameter values were invalid: Type mismatch for key X expected: S actual: M
- DynamoDB Internal Server Error
- ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;
- DynamoDB Update Not Working
- DynamoDB scan filter not working
- dynamodb does not accept empty set
- DynamoDB attribute not empty
- DynamoDB FilterExpression Not Working
- DynamoDB missing items
- dynamodb stream missing fields
- DynamoDB string set cannot be empty
- DynamoDB Query Limit Not Working
- dynamodb property projection cannot be empty
- AWS Lambda DynamoDB Stream Error
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today