GCloud Upload Httplib2.RedirectMissingLocation: Redirected But The Response Is Missing A Location: Header
Solution 1:
Solutions
gcloud
package is deprecated twice and is not compatible with httplib2>=0.16
. Proper solution is to use google-cloud-*
packages family.
google-api-python-client>=1.7.12
is using redirect_codes API, please upgrade, it just works.
httplib2 v0.17.0 is just released with ability to modify set of response codes treated as redirects. This is the best option if you can modify code that creates Http
object:
http = httplib2.Http()
http.redirect_codes = http.redirect_codes - {308}
Iff that's not possible, edit your requirements.txt to pin down httplib2<0.16.0
Long story
google cloud storage server uses HTTP 308 for special resumable uploads feature which somewhat resembles "retry same method to same location", but not quite.
Above is (probably) rationale for PyPI package google-resumable-media which is used by more recent incarnations of gcloud related packages and handles 200 and 308 in similar manner, unlike generic HTTP client should.
History context:
- 2016 package gcloud was deprecated in favor of package
google-cloud
- 2017 google-cloud-python switches HTTP transport from httplib2 to requests
- 2018 package google-cloud was deprecated again in favor of google-cloud-* packages
- 2020 httplib2 v0.16 gained support for 308 redirects per RFC7538
Sorry for bad news. As HTTP enthusiast, I'm biased towards 308 support. Please reach if you have better idea how to handle this situation more gracefully.
Solution 2:
I solved this problem with:
pip install httplib2==0.15.0
pip install google-api-python-client==1.6
Edit: faster on load is: pip install httplib2==0.15.0 pip install google-api-python-client==1.7.11
Solution 3:
Downgrade your httplib2
version to 0.15.0
. Worked for me on the python google-cloud-sdk.
Solution 4:
I had this error on Dataflow (masquerading also as a BrokenPipe). Downgrading google-api-python-client
to the versions >=1.7.8,<1.7.12
fixed it, because 1.7.12 introduced a dependency on httplib2 0.17.0 which was somehow incompatible.
Post a Comment for "GCloud Upload Httplib2.RedirectMissingLocation: Redirected But The Response Is Missing A Location: Header"