Error: DynamoDB Scan Not Working

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
A single Scan request reads only one page, up to its Limit or the service's 1 MB page boundary, then applies the filter. An empty Items array can therefore still have a LastEvaluatedKey and more data to read.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";
const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));
let key;
do {
const page = await db.send(new ScanCommand({
TableName: "Orders",
ExclusiveStartKey: key,
}));
for (const item of page.Items ?? []) console.log(item);
key = page.LastEvaluatedKey;
} while (key && Object.keys(key).length > 0);Use the returned key unchanged as ExclusiveStartKey with the same query settings. Count and ScannedCount describe the current page, not the whole table. Limit caps evaluated items before filtering.
If no items match, check the filter values and types, index projection, account, Region and endpoint. If a request throws, handle its actual permission, throttling or validation error. Scans can consume substantial read capacity; use Query for an indexed access pattern and avoid loading an entire large table into memory. Even a strongly consistent scan is not a snapshot of all items at one instant.
See pagination and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- DynamoDB Is Unsupported It Cannot Be Instantiated
- Could not connect to the endpoint URL https:dynamodb.singapore.amazonaws.com
- dynamodb the parameter cannot be converted to a numeric value NaN
- dynamodb table not exists
- ConfigError: Missing region in config
- dynamodb put item not working
- AWS DynamoDB errors ResourceNotFoundException
- DynamoDB consistent read not working
- DynamoDB stream lambda error
- boto3 dynamodb unable to locate credentials
- DynamoDB - The Security Token Included In The Request Is Invalid
- dynamodb condition does not exist
- dynamodb 1 validation error detected value
- DynamoDB no attribute schema defined
- DynamoDB query is slow
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable