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

Bug Report: Exception when calling .upload_from_string() #811

Open
ShwetanshuSingh opened this issue Jul 21, 2021 · 3 comments
Open

Bug Report: Exception when calling .upload_from_string() #811

ShwetanshuSingh opened this issue Jul 21, 2021 · 3 comments
Assignees
Labels
needs more info This issue needs more information from the customer to proceed. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ShwetanshuSingh
Copy link

ShwetanshuSingh commented Jul 21, 2021

Bug similar to #663

Environment details

  • OS: Debian GNU/Linux 10 (buster)
  • Python version: 3.7.3
  • pip version: 21.1.3
  • google-auth version: 1.33.1

Steps to reproduce

  1. Running the following function:
def create_folder(bucket_name, destination_blob_name):
    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)

    blob.upload_from_string('', content_type='application/x-www-form-urlencoded;charset=UTF-8')

results in the traceback:

    blob.upload_from_string('', content_type='application/x-www-form-urlencoded;charset=UTF-8')
  File "/path/to/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 2858, in upload_from_string
    retry=retry,
  File "/path/to/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 2585, in upload_from_file
    retry=retry,
  File "/path/to/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 2387, in _do_upload
    retry=retry,
  File "/path/to/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 1908, in _do_multipart_upload
    transport, data, object_metadata, content_type, timeout=timeout
  File "/path/to/lib/python3.7/site-packages/google/resumable_media/requests/upload.py", line 146, in transmit
    timeout=timeout,
  File "/path/to/lib/python3.7/site-packages/google/resumable_media/requests/_request_helpers.py", line 136, in http_request
    return _helpers.wait_and_retry(func, RequestsMixin._get_status_code, retry_strategy)
  File "/path/to/lib/python3.7/site-packages/google/resumable_media/_helpers.py", line 177, in wait_and_retry
    response = func()
  File "/path/to/lib/python3.7/site-packages/google/auth/transport/requests.py", line 476, in request
    self.credentials.before_request(auth_request, method, url, request_headers)
  File "/path/to/lib/python3.7/site-packages/google/auth/credentials.py", line 133, in before_request
    self.refresh(request)
  File "/path/to/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py", line 111, in refresh
    self._retrieve_info(request)
  File "/path/to/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py", line 91, in _retrieve_info
    self._service_account_email = info["email"]
TypeError: string indices must be integers

Thanks!

@ShwetanshuSingh ShwetanshuSingh changed the title Bug Report: Exception when calling .upload_from_string( Bug Report: Exception when calling .upload_from_string() Jul 21, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jul 21, 2021
@busunkim96 busunkim96 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 24, 2021
@busunkim96 busunkim96 self-assigned this Jul 24, 2021
@busunkim96 busunkim96 removed the triage me I really want to be triaged. label Jul 24, 2021
@busunkim96
Copy link
Contributor

Hi @ShwetanshuSingh,

Apologies for the late response. I see the code seems to be failing in compute_engine/credentials.py. Could you share what environment the code was being run in? Were you in a Google environment like Compute Engine, App Engine, or Functions?

@busunkim96 busunkim96 added the needs more info This issue needs more information from the customer to proceed. label Oct 1, 2021
@tseaver
Copy link
Contributor

tseaver commented Dec 1, 2021

@ShwetanshuSingh The traceback indicates that info is a string, rather than the expected dict. Digging down, _metadata.get_service_account_info calls _metadata.get, which only returns a string if the metadata server returns a non-JSON response (which should never happen).

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jan 17, 2022
@arithmetic1728
Copy link
Contributor

please provide more information if the problem persists, thanks.

@arithmetic1728 arithmetic1728 added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Mar 30, 2022
@yoshi-automation yoshi-automation removed the 🚨 This issue needs some love. label Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants