You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Trying to delete a file that doesn't exist with Bucket.delete_blobs should call the function passed to the on_error arg (if provided) instead of raising an exception. That's the behavior I observe when calling this method normally, but trying to do this inside a batch deletion seems to ignore the passed function and throw the exception anyway (instead of calling the function like I'd expect).
This appears to be closely related to issue #31, but seemed a distinct enough use case to be worth mentioning.
Environment details
OS: Windows 10 Enterprise, Version 1909
Python version: 3.9.6
pip version: 21.2.4 (using the poetry package manager, v1.1.11)
google-cloud-storage version: 1.43.0
Steps to reproduce
Create a bucket in a Google Cloud project and confirm you can connect to it from a Python script on your machine (GOOGLE_APPLICATION_CREDENTIALS set, etc).
Run the example code below on the machine with at least 1 name in filenames that doesn't exist in the bucket.
Confirm that print_blob_name is executed if the with gcs_client.batch(): line is removed, but an exception is thrown instead when it's present.
Traceback (most recent call last):
File "C:\Users\jd185367\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\jd185367\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\jd185367\<redacted>\gcs_deletion_test.py", line 11, in <module>
bucket.delete_blobs(filenames, on_error=print_blob_name)
File "C:\Users\jd185367\AppData\Local\pypoetry\Cache\virtualenvs\<redacted>-I8hA3ptd-py3.9\lib\site-packages\google\cloud\storage\batch.py", line 299, in __exit__
self.finish()
File "C:\Users\jd185367\AppData\Local\pypoetry\Cache\virtualenvs\<redacted>-I8hA3ptd-py3.9\lib\site-packages\google\cloud\storage\batch.py", line 285, in finish
self._finish_futures(responses)
File "C:\Users\jd185367\AppData\Local\pypoetry\Cache\virtualenvs\<redacted>-I8hA3ptd-py3.9\lib\site-packages\google\cloud\storage\batch.py", line 261, in _finish_futures
raise exceptions.from_http_response(exception_args)
google.api_core.exceptions.NotFound: 404 BATCH contentid://None: No such object: bucket-name/non_existent.png
Trying to delete a file that doesn't exist with
Bucket.delete_blobsshould call the function passed to theon_errorarg (if provided) instead of raising an exception. That's the behavior I observe when calling this method normally, but trying to do this inside a batch deletion seems to ignore the passed function and throw the exception anyway (instead of calling the function like I'd expect).This appears to be closely related to issue #31, but seemed a distinct enough use case to be worth mentioning.
Environment details
poetrypackage manager, v1.1.11)google-cloud-storageversion: 1.43.0Steps to reproduce
GOOGLE_APPLICATION_CREDENTIALSset, etc).filenamesthat doesn't exist in the bucket.print_blob_nameis executed if thewith gcs_client.batch():line is removed, but an exception is thrown instead when it's present.Code example
Stack trace