Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

bucket.delete(force=True) does not work if versioning is enabled #1071

Closed

Description

@irigon

Environment details

  • OS type and version: Alpine Linux
  • Python version: python --version: Python 3.11.4
  • pip version: pip --version: pip 23.1.2 from /opt/venv-azcli/lib/python3.11/site-packages/pip (python 3.11)
  • google-cloud-storage version: pip show google-cloud-storage: 2.10.0

Steps to reproduce

Create a versioned bucket
Add some data
Exclude bucket forcefully.

While it would be expected that all blobs are deleted and the bucket excluded, it returns 409.

Code example

storage_client = storage.Client(credentials=mycredentials,project=myproject)
bucket_name = 'sa-bk3-hec42-cis-tmp'
bucket = storage_client.create_bucket(bucket_name, location="EUROPE-WEST4")
bucket.versioning_enabled = True
bucket.patch()

blob = storage.Blob(name=f"wrapper/test", bucket=bucket)
blob.upload_from_string(data='decomission', content_type="text/plain")

bucket = storage_client.get_bucket(bucket_name)
bucket.delete(force=True)

Stack trace

(<class 'google.api_core.exceptions.Conflict'>, Conflict('DELETE https://storage.googleapis.com/storage/v1/b/sa-bk3-hec42-cis-tmp?prettyPrint=false: The bucket you tried to delete is not empty.'), <traceback object at 0x102c416c0>)

Expected Result

According to the documentation, If force=True is passed, this will first attempt to delete all the objects / blobs in the bucket (i.e. try to empty the bucket).
Besides, 409 should indicates that the bucket name is not available. This error number seems to be misleading.

Activity

  1. added
    api: storage
    on Jul 6, 2023
  2. changed the title [-]bucket.delete(force=True) does not work if [/-] [+]bucket.delete(force=True) does not work if versioning is enabled[/+] on Jul 6, 2023
  3. added
    type: bug
    priority: p2
    on Jul 11, 2023
  4. self-assigned this
    on Jul 12, 2023
  5. added a commit that references this issue on Oct 31, 2023
    0de09d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storagepriority: p2type: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions