You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
The issue is the Python library does a metadata get on an Object which includes kmsKeyName version resource ID metadata.
If you use the same Blob instance to perform an upload the Python library will use the kmsKeyName version resource ID instead of the kmsKeyName resource ID.
Cloud Storage API expects the kmsKeyName kmsKeyName without version information.
Here's an example for illustration:
kmsKeyName version resource ID:
fromgoogle.cloudimportstoragebucket_name='your-bucket-name'blob_name='your-object-name'client=storage.Client()
bucket=client.bucket(bucket_name)
# Creates a random encrypted blob.blob=bucket.blob(blob_name)
blob.upload_from_string("oldcontent")
blob.upload_from_string("newcontent", if_generation_match=blob.generation)
Workaround
fromgoogle.cloudimportstoragebucket_name='your-bucket-name'blob_name='your-object-name'client=storage.Client()
bucket=client.bucket(bucket_name)
# Creates a random encrypted blob.blob=bucket.blob(blob_name)
blob.upload_from_string("oldcontent")
# Store the generationsaved_generation=blob.generation# Get a new instance of Blob to unset value of kmsKeyNameblob=bucket.blob(blob_name)
blob.upload_from_string("newcontent", if_generation_match=saved_generation)
Potential Fix:
blob.upload_from_* should only use kmsKeyName if it doesn't end with a version.
Tracking issue for a customer.
The issue is the Python library does a metadata get on an Object which includes kmsKeyName version resource ID metadata.
If you use the same Blob instance to perform an upload the Python library will use the kmsKeyName version resource ID instead of the kmsKeyName resource ID.
Cloud Storage API expects the kmsKeyName kmsKeyName without version information.
Here's an example for illustration:
kmsKeyName version resource ID:
kmsKeyName resource ID:
Reproduction
Workaround
Potential Fix:
blob.upload_from_*should only use kmsKeyName if it doesn't end with a version.