GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — storage: cannot access / delete versioned objects · Issue #2463 · googleapis/google-cloud-python

storage: cannot access / delete versioned objects #2463

New issue
Copy link
New issue
Copy link
Closed
Closed
storage: cannot access / delete versioned objects#2463
Copy link
Assignees
tseaver
Labels
api: storageIssues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@pdknsk
pdknsk
opened on Sep 29, 2016
Issue body actions

Currently, blob.delete and bucket.delete_blob always delete the live version on buckets with versioning enabled. Other than being a missing feature, this can also cause some very unwanted behaviour, if a new version of the object is uploaded during the process of getting and deleting an object.

--- a/blob.py
+++ b/blob.py
@@ -279,7 +279,8 @@
                  (propagated from
                  :meth:`gcloud.storage.bucket.Bucket.delete_blob`).
         """
-        return self.bucket.delete_blob(self.name, client=client)
+        return self.bucket.delete_blob(self.name, self.generation, 
+            client=client)

     def download_to_file(self, file_obj, encryption_key=None, client=None):
         """Download the contents of this blob into a file-like object.
--- a/bucket.py
+++ b/bucket.py
@@ -357,7 +357,7 @@
         client.connection.api_request(method='DELETE', path=self.path,
                                       _target_object=None)

-    def delete_blob(self, blob_name, client=None):
+    def delete_blob(self, blob_name, generation=None, client=None):
         """Deletes a blob from the current bucket.

         If the blob isn't found (backend 404), raises a
@@ -392,6 +392,8 @@
         """
         client = self._require_client(client)
         blob_path = Blob.path_helper(self.path, blob_name)
+        if generation:
+            blob_path += '?generation=%i' % generation
         # We intentionally pass `_target_object=None` since a DELETE
         # request has no response value (whether in a standard request or
         # in a batch request).

Activity

  1. tseaver
    added
    api: storageIssues related to the Cloud Storage API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Sep 29, 2016
  2. tseaver commented on Sep 29, 2016

    @tseaver
    tseaver
    on Sep 29, 2016
    Contributor
    More actions

    @pdknsk Thanks for the report! You are correct that we currently have no support for addressing a specific generation of a blob.

    ISTM that the generation flag should probably be passed to Blob.__init__ (and through Bucket.blob(), because it should affect other operations as well.

    API endpoints taking the generation query string parameter, which should be mapped from the blob's generation property, if set:

    • https://cloud.google.com/storage/docs/json_api/v1/objects/get
    • https://cloud.google.com/storage/docs/json_api/v1/objects/delete
    • https://cloud.google.com/storage/docs/json_api/v1/objects/getIamPolicy
    • https://cloud.google.com/storage/docs/json_api/v1/objects/insert (?!)
    • https://cloud.google.com/storage/docs/json_api/v1/objects/patch (?!)
    • https://cloud.google.com/storage/docs/json_api/v1/objects/setIamPolicy (?!)
    • https://cloud.google.com/storage/docs/json_api/v1/objects/testIamPermissions
    • https://cloud.google.com/storage/docs/json_api/v1/objects/update (?!)

    The (?!) is because it confounds my expectations to be updating a historical generation of the resource: I thought I understood that updating the current version was how a new generation gets created.

    API endpoints taking the source_generation query string parameter, which would be mapped from the source blob's generation property, if set:

    • https://cloud.google.com/storage/docs/json_api/v1/objects/copy
    • https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite

    We should probably also plan to support the various "conditional" parameters that these APIs support (ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch, ifMetagenerationNotMatch).

  3. pdknsk commented on Sep 29, 2016

    @pdknsk
    pdknsk
    on Sep 29, 2016
    Author
    More actions

    The (?!) is for metadata I think, which can be updated on archived objects.

    https://cloud.google.com/storage/docs/object-versioning#_UpdatingMetadata

    https://cloud.google.com/storage/docs/generations-preconditions#examples_of_race_conditions

  4. pdknsk commented on Sep 30, 2016

    @pdknsk
    pdknsk
    on Sep 30, 2016
    Author
    More actions

    Implementing preconditions is probably not necessary when generation is always set, as that takes care of every scenario in which preconditions apply, I think.

  5. lukesneeringer
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Apr 19, 2017
  6. tseaver
    changed the title [-]storage: cannot delete non-live versioned objects[/-] [+]storage: cannot access / delete versioned objects[/+] on Jun 5, 2017
  7. lukesneeringer
    removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Aug 11, 2017
  8. evanj commented on Sep 8, 2017

    @evanj
    evanj
    on Sep 8, 2017
    Contributor
    More actions

    This is closely related but maybe not the same, let me know if I should create a new issue: I'd love support for preconditions. I personally only need "upload blob only if it does not exist", and not full support. I'm contemplating some gross hacks to do this, although for now I'm going with the "incorrect" version of checking exists() first.

    Reacted by William
  9. jdmargulici commented on Oct 30, 2017

    @jdmargulici
    jdmargulici
    on Oct 30, 2017
    More actions

    Is there a roadmap that covers this issue and/or can I volunteer some help?

  10. chemelnucfin
    assigned
    tseaver
    and
    chemelnucfin
    on Jan 15, 2018
  11. chemelnucfin commented on Jan 16, 2018

    @chemelnucfin
    chemelnucfin
    on Jan 16, 2018
    Contributor
    More actions

    Related to #4533 and #4490

  12. chemelnucfin commented on Jan 22, 2018

    @chemelnucfin
    chemelnucfin
    on Jan 22, 2018
    Contributor
    More actions

    Hello, feature requests will now be tracked in the project Feature Requests. I will close this issue now, please feel free to continue to address any issues/concerns here.

  13. chemelnucfin
    closed this as completedon Jan 22, 2018
  14. theacodes
    unassigned
    chemelnucfin
    on Sep 28, 2018
  15. parthea
    added 2 commits that reference this issue on Apr 1, 2026

    feat: Update bigquery.ai.generate_table output_schema to allow Mappin…

    9c33ed4

    chore: librarian release pull request: 20260303T181914Z (#2489)

    72b1c96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: storageIssues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.