This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Description Environment details
OS type and version: variant of Debian Linux
Python version: 3.8.5
pip version: 20.1.1
google-cloud-storage version: 1.31.2
Steps to reproduce
create Blob object using from_string without a specified client
use Blob upload_from_string with client argument
Code example
from google .cloud import storage
from google .cloud .storage .blob import Blob
def reproduce_error ():
storage_client = storage .Client ()
blob = Blob .from_string ("gs://jdimatteo-gunk/example/upload_from_string_error/reproduce_error.txt" )
blob .upload_from_string ("foo" , client = storage_client )
def workaround_1 ():
storage_client = storage .Client ()
blob = Blob .from_string (
"gs://jdimatteo-gunk/example/upload_from_string_error/workaround_1.txt" ,
client = storage_client )
blob .upload_from_string ("workaround_1\n " )
def workaround_2 ():
storage_client = storage .Client ()
blob = Blob .from_string ("gs://jdimatteo-gunk/example/upload_from_string_error/workaround_2.txt" )
blob .bucket ._client = storage_client
blob .upload_from_string ("workaround_2\n " )
workaround_1 ()
workaround_2 ()
reproduce_error ()
Stack trace
$ python example.py
Traceback (most recent call last):
File "example.py", line 24, in <module>
reproduce_error()
File "example.py", line 7, in reproduce_error
blob.upload_from_string("foo", client=storage_client)
File "/usr/local/google/home/jdimatteo/gunk/upload_from_string_error_example/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 2440, in upload_from_string
self.upload_from_file(
File "/usr/local/google/home/jdimatteo/gunk/upload_from_string_error_example/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 2223, in upload_from_file
created_json = self._do_upload(
File "/usr/local/google/home/jdimatteo/gunk/upload_from_string_error_example/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 2055, in _do_upload
response = self._do_multipart_upload(
File "/usr/local/google/home/jdimatteo/gunk/upload_from_string_error_example/venv/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 1614, in _do_multipart_upload
hostname=self.client._connection.API_BASE_URL, bucket_path=self.bucket.path
AttributeError: 'NoneType' object has no attribute '_connection'
$ gsutil cat gs://jdimatteo-gunk/example/upload_from_string_error/workaround_1.txt
workaround_1
$ gsutil cat gs://jdimatteo-gunk/example/upload_from_string_error/workaround_2.txt
workaround_2
Reactions are currently unavailable
Environment details
google-cloud-storageversion: 1.31.2Steps to reproduce
Blobobject usingfrom_stringwithout a specifiedclientBlobupload_from_stringwithclientargumentCode example
Stack trace