A bulk delete to an S3-compatible bucket can come back with HTTP 200 and still leave objects behind. The answer is in the body: every key that failed has its own error entry. If your code only checks the status, you will report a clean bucket that is not clean.
We built a small S3 stand-in that fails the same keys every run, pointed boto3, the AWS CLI and rclone at it, and counted what each one did. Same 2,500 objects every time, so you can repeat it.
The test setup
- 2,500 objects named
file-0000.txttofile-2499.txt, so three DeleteObjects requests (1,000 + 1,000 + 500). - 25 transient keys (index ends in 13 when divided by 100): answer
InternalErrorthe first two times they are in a request, then delete fine. - 10 permanent keys (index leaves 7 when divided by 250): answer
AccessDeniedevery time and stay. - Every response is HTTP 200, as S3 does for a request it understood. Like S3, the stand-in refuses a request with no checksum header and one with more than 1,000 keys.
Three ways to loop over the keys
| Strategy | HTTP statuses | Keys sent | Objects left | Told you? |
|---|---|---|---|---|
| Check the status only | 200, 200, 200 | 2,500 | 35 | No |
| Retry everything, 3 passes | all 200 | 7,500 | 10 | No: 10 left, nothing says why |
| Retry only failed keys | all 200 | 2,550 | 10 | Yes: the 10 keys with their error code |
The failed-key loop sent 2,500 keys in round 1, then 25 in round 2 and 25 in round 3, when the 25 transient keys finally went through. It is 4,950 fewer keys than three full passes.
The loop that works
Treat the error code as the decision: retry the ones that can succeed later, report the ones that cannot. Do not retry AccessDenied; it will fail the same way every time.
- Quiet mode returns only the failures. On the first 1,000 keys the verbose answer listed 986
Deletedand 14 errors; quiet listed 0 and the same 14. For big batches quiet is a smaller answer with the same information. - Whole-request failures are a different case. When the stand-in answered one request with 503 SlowDown, boto3 retried it by itself (the server saw 503, then 200). With the SDK's retries switched off it raised
ClientError: SlowDownand deleted nothing. The SDK does not retry per-key errors inside a 200. - 1,001 keys in one request were refused with
MalformedXML. Split at 1,000.
What the command-line tools do
| Command | Requests it made | Exit code | Objects left |
|---|---|---|---|
aws s3api delete-objects (aws-cli/1.46.3), first 1,000 keys | 1 DeleteObjects | 0 (14 errors printed as JSON) | 14 of 1,000 |
aws s3 rm --recursive (aws-cli/1.46.3) | 2,500 DeleteObject, 0 DeleteObjects | 1 | 10 |
rclone delete (v1.76.0) | about 2,544 DeleteObject, 0 DeleteObjects | 1 | 10 |
Two things to take from that. The raw API call (<code>s3api delete-objects</code>) exits 0 even though 14 keys failed, so a shell script has to read the JSON, not the exit code. The friendlier commands (<code>aws s3 rm</code>, <code>rclone delete</code>) delete one key per request, so they never see this response at all, and they exit non-zero when a key fails. rclone's request count moved between runs (it retries failed deletes itself), so read that one as a rough figure.
What to do with this
- Read
Errors(boto3) or theErrorelements (raw XML) after every DeleteObjects call, not the status. - Retry only the keys that failed, with a pause that doubles, and a round limit.
- Split permanent from retryable by code, and put the permanent keys in your log or your report.
- Compare the count you meant to delete with a listing at the end if the delete matters (a cleanup before closing an account, say).
The same advice holds on any S3-compatible bucket, including a tport.space bucket: the response format comes from the S3 API. If you copy first and delete later, verifying a bucket copy covers the check before you delete.
S3-compatible buckets with no egress fees, for the files you clean up and the ones you keep.
Explore tport.spaceTest record and sources
- Run on 2026-11-15 on one Mac, loopback only: Python 3.12, boto3 1.44.3, aws-cli/1.46.3, v1.76.0. The stand-in is not tport.space or AWS; it shows how clients react to the response shape, not how any real service behaves under load. Error codes and the failure pattern are ours, chosen to be fixed.
- AWS docs: DeleteObjects (up to 1,000 keys; per-key success or failure in the response; verbose and quiet modes; Content-MD5 or a checksum header required), boto3 delete_objects (Deleted and Errors in the response).