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

Custom metadata not included in HTTP headers when using storage emulator #187

Open
cortadocodes opened this issue Jun 29, 2022 · 0 comments

Comments

@cortadocodes
Copy link

Describe the bug

When custom metadata is added to a cloud object and you access it via an HTTP GET request, each key-value pair should be included in the response headers with the prefix x-goog-meta-<key>. These key-value pairs are missing from the response headers when the storage emulator is used.

For example, if I add this metadata to a cloud object:

{"some": "metadata"}

then there should be a header in the response that looks like this:

{"x-goog-meta-some": "metadata"}

Instead, the only headers included in the response are:

{
    'Server': 'BaseHTTP/0.6 Python/3.9.13', 
    'Date': 'Wed, 29 Jun 2022 15:59:33 GMT', 
    'X-Goog-Hash': 'crc32c=pdRKBQ==,md5=vrakOt+5UOxvgs7tGb7uIQ==', 
    'Content-type': 'text/plain',
    'Content-Length': '10'
}

To Reproduce

With the emulator running, execute the following python script:

import requests        
from google.cloud import storage


client = storage.Client()
client.create_bucket("my-bucket")

blob = client.get_bucket("my-bucket").blob(blob_name="my_file.txt")
blob.upload_from_string("blah blah blah")
blob.metadata = {"some": "metadata"}
blob.patch()

url = f"{os.environ['STORAGE_EMULATOR_HOST']}/my-bucket/my_file.txt"
response = requests.get(url)
assert response.headers["x-goog-meta-some"] == "metadata"

This will raise:

KeyError: 'x-goog-meta-some'

Expected behavior

Custom metadata (key-value pairs) should appear in the headers as key-value pairs like:

x-goog-meta-<key>: <value>

System (please complete the following information)

  • OS version: MacOS Monterey 12.4
  • Python version: 3.9.13
  • gcp-storage-emulator version: 2022.06.11

Additional context

I came across this while creating signed URLs to cloud objects and attempting to get their metadata, but this problem occurs for all URLs to cloud objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant