Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Can't delete custom metadata key on object #381

Description

@hankd-v

I ran into some issues trying to delete a custom metadata key from a storage object. I expected the following to work, but did not result in the key being deleted:

# blob has metadata with key 'foo'new_metadata= {}
forxinblob.metadata:
ifx!='foo':
new_metadata[x] =blob.metadata[x]
# new_metadata is now a copy of the metadata without key 'foo'blob.metadata=new_metadatablob.patch()
# The blob's metadata still has key 'foo'

The Rest API indicated to send a value of JSON null associated with the key to perform a deletion, but that doesn't seem to happen when issuing a blob.patch with a metadata with a key removed.

As a work around, I created a copy of the desired metadata, deleted all of the blob's metadata (which does work), then updated the metadata to be the desired metadata.

new_metadata= {}
forxinblob.metadata:
ifx!='foo':
new_metadata[x] =blob.metadata[x]
blob.metadata=Noneblob.patch()
blob.metadata=new_metadatablob.patch()

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.priority: p2Moderately-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions