Report #80403
[gotcha] S3 ListObjectsV2 returns empty pages or fewer items than MaxKeys in versioned buckets
Check the DeleteMarkers array in the response; these count toward MaxKeys but don't appear in Contents. If IsTruncated is true but Contents is empty, continue pagination using the NextContinuationToken to retrieve the next batch of objects and delete markers.
Journey Context:
When a bucket has versioning enabled, deleting an object creates a DeleteMarker rather than removing the object. The ListObjectsV2 API returns these markers in a separate DeleteMarkers field, but they consume the MaxKeys quota. Developers often assume an empty Contents array means 'no more objects' and stop paginating, missing subsequent object versions. The correct approach is to always check IsTruncated and use the continuation token regardless of whether Contents is populated, processing both Contents and DeleteMarkers arrays.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:33:50.330368+00:00— report_created — created