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

blob.download_as_string() raises TypeError: expected string or bytes-like object in version 1.41.0 #510

Closed
TheBirdsNest opened this issue Jul 16, 2021 · 3 comments
Assignees
Labels
api: storage Issues related to the googleapis/python-storage API. 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.

Comments

@TheBirdsNest
Copy link

Version google-cloud-storage==1.41.0

When calling blob.download_as_string() we get a TypeError.

Working in version 1.40.0

Error Output:

unencrypted_secret = self.decrypt(blob.download_as_string())
File "/usr/local/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 1520, in download_as_string
warnings.warn(
TypeError: expected string or bytes-like object
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Jul 16, 2021
@WildSunLove
Copy link
Contributor

Hi @TheBirdsNest, thanks for this report!

This was actually just reported and addressed in #501 and #504

Long story short; download_as_string() is deprecated, but our deprecation message had a lingering comma that caused it to be the wrong type, so it doesn't tell you that it's deprecated, it just fails. You should be able to fix this by replacing download_as_string() with download_as_bytes()

If you could give that a try and let us know if that works or if you run into any issues, that would be great, thanks!

@WildSunLove WildSunLove self-assigned this Jul 16, 2021
@WildSunLove WildSunLove 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 17, 2021
@oxytis
Copy link

oxytis commented Jul 18, 2021

changing to download_as_bytes works. initially tracking this down in GAE code was a challenge. gcloud app deploying the same code as of the deprecation resulted in this area "somewhere in the code". Reverted to previous version, same code, worked fine, until I could debug and find the specific function that cause this error.

@TheBirdsNest
Copy link
Author

Thanks @Breathtender; that worked perfectly.
Apologies for not doing a thorough enough search for already open issues!

I appreciate the quick response :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. 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.
Projects
None yet
Development

No branches or pull requests

3 participants