Title: Can't delete custom metadata key on object · Issue #381 · googleapis/python-storage · GitHub
Open Graph Title: Can't delete custom metadata key on object · Issue #381 · googleapis/python-storage
X Title: Can't delete custom metadata key on object · Issue #381 · googleapis/python-storage
Description: 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 = {} for x in blob.metada...
Open Graph Description: 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...
X Description: 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 '...
Opengraph URL: https://github.com/googleapis/python-storage/issues/381
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't delete custom metadata key on object","articleBody":"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:\r\n\r\n```python\r\n# blob has metadata with key 'foo'\r\nnew_metadata = {}\r\nfor x in blob.metadata:\r\n if x != 'foo':\r\n new_metadata[x] = blob.metadata[x]\r\n# new_metadata is now a copy of the metadata without key 'foo'\r\nblob.metadata = new_metadata\r\nblob.patch()\r\n# The blob's metadata still has key 'foo'\r\n```\r\n\r\nThe 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.\r\n\r\nAs 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.\r\n```python\r\nnew_metadata = {}\r\nfor x in blob.metadata:\r\n if x != 'foo':\r\n new_metadata[x] = blob.metadata[x]\r\nblob.metadata = None\r\nblob.patch()\r\nblob.metadata = new_metadata\r\nblob.patch()\r\n```","author":{"url":"https://github.com/hankd-v","@type":"Person","name":"hankd-v"},"datePublished":"2021-02-16T19:49:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/381/python-storage/issues/381"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c4d528d6-027c-8dd7-6e40-9561da61e0ae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCC4:91DE5:C1F8FE:11CE06B:6A4E2471 |
| html-safe-nonce | f892cc9afbf2b652b9405fe10bcadeae1be41406e730b4192296c4047fbcb819 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0M0OjkxREU1OkMxRjhGRToxMUNFMDZCOjZBNEUyNDcxIiwidmlzaXRvcl9pZCI6Ijc3NzkzNzM1MjY1NzAzNzgzNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3e0420f363e2e81210b323dbba9f0b0d6aebcfeeaa4b9b0bc1e0b6109a8c5533 |
| hovercard-subject-tag | issue:809599979 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-storage/381/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b837a3f522a5bb1eb6cb3e40268ddb2299a1451c85f216e56d34c6157067922e/googleapis/python-storage/issues/381 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b837a3f522a5bb1eb6cb3e40268ddb2299a1451c85f216e56d34c6157067922e/googleapis/python-storage/issues/381 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hankd-v |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-storage git https://github.com/googleapis/python-storage.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992639 |
| octolytics-dimension-repository_nwo | googleapis/python-storage |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992639 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-storage |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d9dd20d38f8ae3c4cb6b597807431db300d0bd2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width