Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete retention of a non-current blob fails #2980

Closed
niriak opened this issue Mar 11, 2025 · 0 comments · Fixed by #3006 · May be fixed by #2997
Closed

Delete retention of a non-current blob fails #2980

niriak opened this issue Mar 11, 2025 · 0 comments · Fixed by #3006 · May be fixed by #2997
Assignees
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@niriak
Copy link

niriak commented Mar 11, 2025

Environment details

Maven Artefact: com.google.cloud:google-cloud-storage:2.49.0
OS Type: Linux (Manjaro)
Java version: openjdk version "21.0.6" 2025-01-21

Steps to reproduce

  1. Create a bucket with versioning and object retention enabled
  2. Create a blob with retention in unlocked mode
  3. Delete the blob (live -> non-current)
  4. Delete the non-current blobs retention

Code example

Expected code to delete the non-current blobs retention:

var blobId = BlobId.of("my-bucket", "my-blob-name", 1741083479142854L);
var blob = storage.get(blobId, Storage.BlobGetOption.generationMatch());

var newblob = blob.toBuilder().setRetention(null).build();
newblob.update(Storage.BlobTargetOption.overrideUnlockedRetention(true), Storage.BlobTargetOption.generationMatch());

Stack trace

com.google.cloud.storage.StorageException: No such object: my-bucket/my-blob-name

	at com.google.cloud.storage.StorageException.translate(StorageException.java:209)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:360)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.patch(HttpStorageRpc.java:718)
	at com.google.cloud.storage.StorageImpl.lambda$update$18(StorageImpl.java:592)
	at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:102)
	at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
	at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
	at com.google.cloud.storage.Retrying.run(Retrying.java:65)
	at com.google.cloud.storage.StorageImpl.run(StorageImpl.java:1611)
	at com.google.cloud.storage.StorageImpl.update(StorageImpl.java:590)
	at com.google.cloud.storage.Blob.update(Blob.java:855)
        [...]

Any additional information below

Expected behavior:
The code example deletes the blobs retention.

Actual behavior:
The code fails with an exception, stating the non-current blob is not found

Working workaround:
It looks like the generation information is not send in the update call by default. Marking the blobId generation field as changed seems to force the generation information to be submitted, at least in the current version of the maven artefact.

var newblob = blob.toBuilder().setBlobId(/* trigger a change to the generation */ BlobId.of(blobId.getBucket(), blobId.getName())).setBlobId(/* set generation to the correct one */ blobId).setRetention(null).build();
newblob.update(Storage.BlobTargetOption.overrideUnlockedRetention(true), Storage.BlobTargetOption.generationMatch());

Let me know if you need any more information.

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/java-storage API. label Mar 11, 2025
@BenWhitehead BenWhitehead added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 12, 2025
@BenWhitehead BenWhitehead self-assigned this Mar 12, 2025
BenWhitehead added a commit that referenced this issue Mar 20, 2025
…ing HTTP Transport

If a generation is present in the provided BlobInfo ensure it is sent to GCS. This is
a hard requirement when using versioned buckets and trying to update a non-current
object version.

Effects all version 2.42.0 through 2.50.0

Regression introduced in #2664

Fixes #2980
BenWhitehead added a commit that referenced this issue Mar 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ing HTTP Transport (#3006)

If a generation is present in the provided BlobInfo ensure it is sent to GCS. This is
a hard requirement when using versioned buckets and trying to update a non-current
object version.

Effects all version 2.42.0 through 2.50.0

Regression introduced in #2664

Fixes #2980
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
2 participants