GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Blob upload_from_string AttributeError when using client argument · Issue #286 · googleapis/python-storage

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.

Blob upload_from_string AttributeError when using client argument #286

Copy link
Copy link
Closed
#290
Closed
Blob upload_from_string AttributeError when using client argument#286
#290
Copy link
Assignees
HemangChothani
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.

Description

@jdimatteo
jdimatteo
opened on Oct 1, 2020
Issue body actions

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

  1. create Blob object using from_string without a specified client
  2. 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

Activity

  1. product-auto-label
    added
    api: storageIssues related to the googleapis/python-storage API.
    on Oct 1, 2020
  2. jdimatteo commented on Oct 1, 2020

    @jdimatteo
    jdimatteo
    on Oct 1, 2020
    Author
    More actions

    Here is an example fix: jdimatteo@df00005

    I haven't contributed to this project before and it would take me a little while to get up to speed on the test framework etc.

    I'll create a proper pull request if nobody else gets to this before I do.

  3. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Oct 2, 2020
  4. HemangChothani
    added
    type: questionRequest for information or clarification. Not an issue.
    and removed
    🚨This issue needs some love.
    triage meI really want to be triaged.
    on Oct 8, 2020
  5. HemangChothani
    self-assigned this
    on Oct 8, 2020
  6. HemangChothani
    added
    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.
    and removed
    type: questionRequest for information or clarification. Not an issue.
    on Oct 8, 2020
  7. gcf-merge-on-green
    closed this as completedin #290on Nov 11, 2020
  8. gcf-merge-on-green
    added a commit that references this issue on Nov 11, 2020

    fix: from_string method of blob and bucket class (#290)

    This issue will close once commit d457ce3 is merged into the 'main' branch.
    d457ce3
  9. cojenco
    added 2 commits that reference this issue on Oct 13, 2021

    fix: from_string method of blob and bucket class (googleapis#290)

    This issue will close once commit a73e91e is merged into the 'main' branch.
    a73e91e

    fix: from_string method of blob and bucket class (googleapis#290)

    This issue will close once commit 3ae3a06 is merged into the 'main' branch.
    3ae3a06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @HemangChothani
    HemangChothani

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.