-
Notifications
You must be signed in to change notification settings - Fork 168
Closed
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Tracking issue for a customer.
Unable to rewrite on top of an existing GCS blob in CMEK enabled bucket. Receives a 400 Bad Request with the following repro code. This looks very similar to #155
Environment details
- python 3.9
- google-cloud-storage 2.3.0
Steps to reproduce
- Create a bucket with Customer-managed encryption keys (via Cloud KMS)
- Write blob to bucket
- Overwrite blob
Code example
from google.cloud import storage
bucket_name = 'your-bucket-name'
blob_name1 = 'your-object-name'
blob_name1 = 'your-different-name'
client = storage.Client()
bucket = client.bucket(bucket_name)
blob1 = bucket.get_blob(blob_name1)
blob2 = bucket.get_blob(blob_name2)
blob2.rewrite(blob1)Expected behavior: Success, blob2 is overwritten
Actual behavior: google.api_core.exceptions.BadRequest: 400 POST <...> Bad Cloud KMS crypto key <...>
As long as blob1 and blob2 are not equal and both exist, this issue happens.
Workaround
Either delete blob2 first, then overwrite. OR call blob2 = bucket.blob(blob_name2) instead.
Potential Fix:
blob.rewrite()should only usekms_key_nameif it doesn't end with a version.
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.