Skip to content

create_bucket expects a project even with an emulator "ValueError: Client project not set: pass an explicit project." #699

@oittaa

Description

@oittaa

Thanks for fixing #324. I just noticed that create_bucket still expects a project. Would it make sense that it'd also detect STORAGE_EMULATOR_HOST and use a "fake" project automatically like here?

Environment details

  • OS type and version: MacOS 12.1
  • Python version: python --version Python 3.9.9
  • pip version: pip --version pip 21.3.1
  • google-cloud-storage version: pip show google-cloud-storage 2.1.0

Steps to reproduce

  1. See the example below.

Code example

import os from google.cloud import storage HOST = "localhost" PORT = 9023 BUCKET = "test-bucket" os.environ["STORAGE_EMULATOR_HOST"] = f"http://{HOST}:{PORT}" client = storage.Client() bucket = client.create_bucket(BUCKET)

Stack trace

Traceback (most recent call last): File "/Users/user/workspace/temp/test.py", line 12, in <module> bucket = client.create_bucket(BUCKET) File "/Users/user/workspace/temp/.venv/lib/python3.9/site-packages/google/cloud/storage/client.py", line 940, in create_bucket raise ValueError("Client project not set: pass an explicit project.") ValueError: Client project not set: pass an explicit project. 

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: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions