Boto3: Boto3 delete_objects response does not match documented response

Created on 21 Feb 2016  路  12Comments  路  Source: boto/boto3

libraries
boto3==1.2.4
botocore==1.3.28

Documentation
http://boto3.readthedocs.org/en/latest/reference/services/s3.html#S3.Client.delete_objects

Expected Response

{
    'Deleted': [
        {
            'Key': 'string',
            'VersionId': 'string',
            'DeleteMarker': True|False,
            'DeleteMarkerVersionId': 'string'
        },
    ],
    'RequestCharged': 'requester',
    'Errors': [
        {
            'Key': 'string',
            'VersionId': 'string',
            'Code': 'string',
            'Message': 'string'
        },
    ]
}

Response With Quiet Flag False

{
    'Objects': [
        {'Key': '116/bc9/116bc9f8d82411e59885acbc327d2ce5.jpg'}, 
        {'Key': '116/bcf/116bcf90d82411e5991eacbc327d2ce5.jpg'}, 
        {'Key': '116/bd0/116bd092d82411e5b433acbc327d2ce5.jpg'}
    ], 
    'Quiet': False
}
{
    'ResponseMetadata': {
        'RequestId': 'C239536D56004DFB', 
        'HostId': 'AZZ0TNTB0bRTEnc01PNhJyX9ntA0RyiWnRW8VT+sL8z6zkVdag+ni+KXaLJY6BT1', 
        'HTTPStatusCode': 200
    }, 
    'Deleted': [
        {'Key': '116/bcf/116bcf90d82411e5991eacbc327d2ce5.jpg'}, 
        {'Key': '116/bd0/116bd092d82411e5b433acbc327d2ce5.jpg'}, 
        {'Key': '116/bc9/116bc9f8d82411e59885acbc327d2ce5.jpg'}
    ]
}

Response With Quiet Flag True

{
    'Quiet': True, 
    'Objects': [
        {'Key': '116/bc9/116bc9f8d82411e59885acbc327d2ce5.jpg'}, 
        {'Key': '116/bcf/116bcf90d82411e5991eacbc327d2ce5.jpg'}, 
        {'Key': '116/bd0/116bd092d82411e5b433acbc327d2ce5.jpg'}
    ]
}
{
    'ResponseMetadata': {
        'HTTPStatusCode': 200, 
        'RequestId': '2A4C617AC8C2805A', 
        'HostId': 'aU3wrmcKectFxmH9rGUzi0Nati+55lOqlYX1BxyX2KfgUsTXqJkAG10GKTbeXIC3'
    }
}
api-documentation s3

Most helpful comment

It is now 2020 and they still won't recognize this is a real issue. As it stands, delete_objects method is useless. Since it takes batches of 1000 files as arguments, this would be used to send files to delete in bulk, but because the response does not reflect reality (No confirmation for deletion or errors), the only way for us to know if a file has been deleted from S3, is to look for it in the bucket again.
This beats the purpose of using 'delete_objects' in the first place.

This is NOT a documentation issue, but a functionality issue. But the least you could do is update the docs, to let potential users know this feature is broken, or remove it entirely from the docs, before other people invest more time trying to implement something that just.doesn't.work.

All 12 comments

I'm not sure what's wrong here. There is no Errors because there were no errors, there is no RequestCharged because you don't have requester pays setup, and passing in the Quiet flag won't get rid of the response metadata that botocore collects.

the DeleteMarker boolean value is missing.
my understanding from the documentation is the a list of keys are returned including DeleteMarker (boolean) to indicate success/failure

That value will only show up on a bucket where versioning is enabled. I'll ping the service team about adding doc strings for the outputs.

so currently if you sent a list of keys where versioning is not used. How do the user know if a key was deleted / fail to delete / does not exist or any other issues?

If it successfully deleted, it will show up under Deleted. If it fails, it will show up under Errors with relevant error messages.

where documentation (links?) should I read regarding the details of the response? Is the documentation page I provided earlier not valid?

just double tested again, Deleted will even list objects that does not even exist. there is something wrong with response / documentation

{'ResponseMetadata': {'HostId': 'tN08nswQwRjACegwY75Mfp3FxnqiW9+T44nUqg0lCizOY1Yh2AIhrIXtU0yw2AHn', 'RequestId': 'F48385763F9D81D5', 'HTTPStatusCode': 200}, 
  'Deleted': [{'Key': '262/3bc/2623bce8db5311e5b07bacbc327d2ce5.jpg'}, {'Key': '262/3be/2623bed2db5311e5a1e7acbc327d2ce5.jpg'}, {'Key': 'test2'}, {'Key': 'test1'}, {'Key': 'c43/508/c4350882da6711e5bcd8acbc327d2ce5.jpg'}, {'Key': 'c44/1cb/c441cbd2da6711e5b7b8acbc327d2ce5.jpg'}, {'Key': '262/3bf/2623bfc2db5311e584f9acbc327d2ce5.jpg'}, {'Key': 'c44/1cd/c441cd42da6711e58528acbc327d2ce5.jpg'}, {'Key': 'test4'}, {'Key': 'test3'}]}

I also got myself confused for the same reason. The documentation describes a response for the delete method which doesn't match with the actual response.

Moreover, the response seems to be always the same, whenever the file exists or not in the bucket

Hi guys, the problem still exists,
"the response is always the same, whenever the file exists or not in the bucket"
Do you have any update?
Name: boto3
Version: 1.9.22
Name: botocore
Version: 1.12.22

2019, still there, cmon guys

It returns wrong data, it's not just a "nice to have" thing. And this is not just a documentation (please remove the api-documentation label), this is a bug. There is no point in returning data duplicated from the request, regardless of actual operations performed in S3.

The workaround for this bug is bombarding S3 with requests deleting all files one by one - that's not the way. Could you assign a Bug label and bring it forward pls?

It is now 2020 and they still won't recognize this is a real issue. As it stands, delete_objects method is useless. Since it takes batches of 1000 files as arguments, this would be used to send files to delete in bulk, but because the response does not reflect reality (No confirmation for deletion or errors), the only way for us to know if a file has been deleted from S3, is to look for it in the bucket again.
This beats the purpose of using 'delete_objects' in the first place.

This is NOT a documentation issue, but a functionality issue. But the least you could do is update the docs, to let potential users know this feature is broken, or remove it entirely from the docs, before other people invest more time trying to implement something that just.doesn't.work.

Scientists found multiple vaccines against covid-19 already, but delete_objects response is still useless...

Was this page helpful?
0 / 5 - 0 ratings