google-api-python-client: httplib2 v0.16.0 breaks the library

Recently updated httplib2 library (v0.16.0) have a breaking change causing this Exception:

httplib2.RedirectMissingLocation: Redirected but response is missing a location: header

Steps to reproduce:

  1. pip install --upgrade httplib2
  2. Now use the google drive library to upload a file (This is where I encountered the bug, it may break while using other stuffs a well)

It should either force to use 0.15.0 version of httplib2 or adapt the breaking changes introduced in the new version.

A temporary fix for those using the client library would be to add httplib2==0.15.0 in requirements,txt of the project

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 30 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Side note: what a wonderful ironic mystery this issue number is 308 backwards.

Looks like the error is back… I’ve upgraded ALL libraries to most recent:

google-api-python-client google-auth google-auth-oauthlib google-auth-httplib2

httplib2 v0.17.0 is just released with API to handle this. Sorry, I couldn’t quickly find where to apply the following patch in this repo, aside from samples (which should probably be modified too).

 http = httplib2.Http()
+http.redirect_codes = set(http.redirect_codes) - {308}

@pkenjora Could you please open a new issue referencing this one? Replies to closed issues are more likely to be missed by repo maintainers.

It would also be helpful if you could show the full pip freeze (with versions).

Thanks!

Seeing this issue on httplib2 version 0.18.1 as well (Python 3.6.8)

Pip freeze:

cachetools==4.1.1
certifi==2020.6.20
chardet==3.0.4
google-api-core==1.21.0
google-api-python-client==1.9.3
google-auth==1.18.0
google-auth-httplib2==0.0.3
googleapis-common-protos==1.52.0
httplib2==0.18.1
idna==2.10
oauth2client==4.1.3
protobuf==3.12.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
PyDrive==1.3.1
pytz==2020.1
PyYAML==5.3.1
requests==2.24.0
rsa==4.6
six==1.15.0
uritemplate==3.0.1
urllib3==1.25.9

I had to downgrade to 0.15.0 seeing the above suggestions. I see the above commit - Add compatibility with httplib2 0.16.0+ , but not sure why 0.18 (0.16.0+) is still breaking.

A set of old Airflow tasks failed last night due to this error, it looks like. Should be able to confirm tomorrow that pinning the library is a workaround.

Stack trace looks like this:

image