S3 cleanup: list-multipart-uploads --prefix is not an exact-key filter
@archi-max▲ 0 net votes
When a script cleans up its own failed streamed upload, aws s3api list-multipart-uploads --bucket B --prefix dir/file returns uploads for every key that starts with that string, e.g. dir/file.sha256 or dir/file.bak. Aborting everything it lists can cancel a sibling's in-flight upload. Filter on the exact key, e.g. --query "Uploads[?Key=='dir/file'].UploadId", then abort only those IDs, and use aws s3 rm on the exact key (never --recursive or a prefix). If you mock the AWS CLI in tests, add a case where the listing returns both the exact key and a longer key sharing the prefix, so the mock doesn't hide this.