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 — Operations on Buckets should use Storage.*Option types · Issue #702 · googleapis/google-cloud-java

Operations on Buckets should use Storage.*Option types #702

New issue
Copy link
New issue
Copy link
Closed
#705
Closed
Operations on Buckets should use Storage.*Option types#702
#705
Copy link
Assignees
yoshi-automation
Labels
api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@dimo414
dimo414
opened on Mar 2, 2016
Issue body actions

Some of the static classes in Storage, such as BlobTargetOption which is used by Storage.create(), are also being erroneously used in Bucket. This is problematic because Bucket keys of of path Strings, not BlobInfo instances, and therefore isn't able to extract information like the blob's generation, causing a line like this:

bucket.create(file, data, null, BlobTargetOption.generationMatch());

to fail:

 java.lang.IllegalArgumentException: Option ifGenerationMatch is missing a value
     at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
     at com.google.gcloud.storage.StorageImpl.addToOptionMap(StorageImpl.java:651)
     at com.google.gcloud.storage.StorageImpl.addToOptionMap(StorageImpl.java:643)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:681)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:660)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:695)
     at com.google.gcloud.storage.StorageImpl.optionMap(StorageImpl.java:703)
     at com.google.gcloud.storage.StorageImpl.create(StorageImpl.java:140)
     at com.google.gcloud.storage.StorageImpl.create(StorageImpl.java:129)
     at com.google.gcloud.storage.Bucket.create(Bucket.java:360)

And there is no way in Storage.BlobTargetOption to actually specify a generation.

I don't think Bucket should have any dependency on the Storage.*Option types. There's clearly a good amount of overlap, but I don't think that's a good enough reason for them to share these types. Even where they behave the same it's confusing for the caller.

They could extend from a shared parent if we wanted, but that should be an implementation detail.

I can put together a patch to remove the dependencies on Storage.*Option from Bucket if that's desired.

Activity

Next
  1. mziccard commented on Mar 2, 2016

    @mziccard
    mziccard
    on Mar 2, 2016
    Contributor
    More actions

    Nice catch!
    We should provide dedicated BlobTargetOption and BlobWriteOption in Bucket. I am assigning this to myself and I'll work on it ASAP.

    Reacted by Ivan A Sanchez V
  2. mziccard
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: storageIssues related to the Cloud Storage API.
    on Mar 2, 2016
  3. mziccard
    self-assigned this
    on Mar 2, 2016
  4. mziccard commented on Mar 2, 2016

    @mziccard
    mziccard
    on Mar 2, 2016
    Contributor
    More actions

    #705 adds BlobTargetOption and BlobWriteOption to Bucket and fixes the bug reported by this issue. Storage.BlobListOption is still used in Bucket as it makes little sense to me to copy-paste the class given that it applies as-is.

  5. aozarov
    closed this as completedin #705on Mar 3, 2016
  6. dimo414 commented on Mar 3, 2016

    @dimo414
    dimo414
    on Mar 3, 2016
    Author
    More actions

    You could have Storage.BlobListOption and Bucket.BlobListOption extend a shared parent. That saves too much typing but makes it much clearer to callers that they're doing the right thing. When I was getting set up the Storage/Bucket overlap was one of the more confusing parts of the API.

  7. theacodes
    unassigned
    mziccard
    on Sep 28, 2018
  8. JustinBeckwith
    assigned
    yoshi-automation
    on Feb 1, 2021
  9. github-actions
    added 6 commits that reference this issue on Jun 21, 2022

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    40670bf

    chore: include generated samples dir (#702)

    e8db044

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    b79c418

    chore(main): release 2.1.1 (#704)

    e72c59e

    deps: update dependency com.google.apis:google-api-services-cloudreso…

    ef26145

    chore(main): release 1.2.2 (googleapis#698)

    e19ddb9
  10. 15 remaining items

  11. suztomo
    added a commit that references this issue on Feb 1, 2023

    chore(main): release 2.13.0 (#702)

    06f751e
  12. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(deps): update dependency com.google.cloud:libraries-bom to v23.…

    e30ca05
  13. chingor13
    added a commit that references this issue on Jan 6, 2026

    build(deps): update dependency org.apache.maven.plugins:maven-project…

    46d65fb
  14. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore: Enable Size-Label bot in all googleapis Java repositories (#1381…

    3fa438f
  15. chingor13
    added 2 commits that reference this issue on Feb 24, 2026

    feat: downscoping with credential access boundaries (#702)

    aa7ede1

    chore: release 1.1.0 (#713)

    8e904ac
  16. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v23.…

    a057554
  17. chingor13
    added 2 commits that reference this issue on Mar 12, 2026

    feat: downscoping with credential access boundaries (#702)

    b956605

    chore: release 1.1.0 (#713)

    2a83637
  18. suztomo
    added a commit that references this issue on Mar 23, 2026

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    9525e63
  19. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore: release 0.123.11 (#702)

    361daa2
  20. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore: release 0.123.11 (#702)

    e542f3a
  21. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore: release 1.113.2 (#702)

    3238e87

    chore: release 1.113.2 (#702)

    6803364
  22. benjaminp
    added a commit that references this issue on Jul 13, 2026

    test: small refactor to cmek test (googleapis#702)

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

Metadata

Metadata

Assignees

  • @yoshi-automation
    yoshi-automation

Labels

api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

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.