Bug 994602 - AttributeError: 'MockRequest' object has no attribute 'origin_req_host'
AttributeError: 'MockRequest' object has no attribute 'origin_req_host'
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: python-requests (Show other bugs)
19
Unspecified Unspecified
unspecified Severity high
: ---
: ---
Assigned To: Arun S A G
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-07 11:08 EDT by Jim Minter
Modified: 2013-09-23 14:58 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-09-23 14:58:53 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jim Minter 2013-08-07 11:08:11 EDT
I'm getting the following error and traceback with latest python3-requests and python3 on F19:

Traceback (most recent call last):
  File "/usr/lib/python3.3/site-packages/requests/sessions.py", line 310, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.3/site-packages/requests/sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "/usr/lib/python3.3/site-packages/requests/sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.3/site-packages/requests/adapters.py", line 219, in send
    r = self.build_response(request, resp)
  File "/usr/lib/python3.3/site-packages/requests/adapters.py", line 106, in build_response
    extract_cookies_to_jar(response.cookies, req, resp)
  File "/usr/lib/python3.3/site-packages/requests/cookies.py", line 105, in extract_cookies_to_jar
    jar.extract_cookies(res, req)
  File "/usr/lib64/python3.3/http/cookiejar.py", line 1647, in extract_cookies
    if self._policy.set_ok(cookie, request):
  File "/usr/lib64/python3.3/http/cookiejar.py", line 931, in set_ok
    if not fn(cookie, request):
  File "/usr/lib64/python3.3/http/cookiejar.py", line 952, in set_ok_verifiability
    if request.unverifiable and is_third_party(request):
  File "/usr/lib64/python3.3/http/cookiejar.py", line 707, in is_third_party
    if not domain_match(req_host, reach(request.origin_req_host)):
AttributeError: 'MockRequest' object has no attribute 'origin_req_host'

Upstream, this error is noted at https://github.com/kennethreitz/requests/issues/1379

The upstream recommendation is to upgrade to Requests to 1.2.1 or later.  Can we rebase to the latest release 1.2.3?
Comment 1 Jim Minter 2013-08-07 12:30:38 EDT
For visitors looking for an insecure hack to work around this, try adding the following code to your application:

# https://github.com/kennethreitz/requests/issues/1379
import http.cookiejar
http.cookiejar.is_third_party = lambda request: False
Comment 2 Ralph Bean 2013-08-19 23:50:53 EDT
Sure, let's give it a try.

So many things rely on python-requests... I'll try to let it sit in updates-testing a little longer than usual.
Comment 3 Fedora Update System 2013-08-20 00:03:35 EDT
python-requests-1.2.3-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-requests-1.2.3-2.fc19
Comment 4 Jim Minter 2013-08-22 13:45:33 EDT
Oh dear, this isn't good.

Trying python3-requests-1.2.3-2.fc19, I've found that it's not automatically un-gzipping content received from remote servers like it used to.  Given (as Ralph mentioned) the number of people relying on python-requests, I think that's a show-stopper.

The issue is down to a combination of:
(a) commit https://github.com/kennethreitz/requests/commit/59f916ca4a6a8e55528988cfc1bee445e71c4602 removing functionality in favour of using urllib3 instead, and
(b) the replacement urllib3 functionality being broken in the version of urllib3 that we currently ship.  Specifically, in HTTPResponse.read(), 

...
            if amt is None:
                # cStringIO doesn't like amt=None
                data = self._fp.read()
            else:
                return self._fp.read(amt)

            try:
                if decode_content and decoder:
                    data = decoder(data)
            except (IOError, zlib.error):
...

the return statement shouldn't be there as it prevents the gzip decoder from running.  This is fixed upstream (I've checked that python3-pip install --upgrade urllib3 makes things act as expected).

I'd now suggest the following:
- for F20, rebase python3-requests /and/ python3-urllib to latest upstream
- for F19, reject python3-requests-1.2.3-2, and do one of the following, depending on appetite for risk:
  - rebase python3-requests /and/ python3-urllib to latest upstream, OR
  - try rebasing python3-requests ONLY to 1.2.1 or 1.2.2 (thus missing the commit mentioned above), OR
  - do nothing!
Comment 5 Ralph Bean 2013-08-22 14:09:48 EDT
Well, as long as the updates for python3-requests and python3-urllib go out together.. and as long as we keep them in updates-testing for a hefty amount of time: I think I'm ok with updating them both to the latest upstream in F19.
Comment 6 Fedora Update System 2013-08-22 17:17:31 EDT
python-urllib3-1.7-1.fc19,python-requests-1.2.3-3.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-urllib3-1.7-1.fc19,python-requests-1.2.3-3.fc19
Comment 7 Jim Minter 2013-08-26 10:21:34 EDT
Tested and all works for me -- thanks!

I wonder if it might be worth putting
  Requires: python-urllib3 >= 1.7
and 
  Requires: python3-urllib3 >= 1.7
in the relevant parts of the requests spec file?
Comment 8 Ralph Bean 2013-08-26 10:59:02 EDT
Yes, that sounds smart.
Comment 9 Fedora Update System 2013-08-26 11:39:10 EDT
python-urllib3-1.7-2.fc19,python-requests-1.2.3-4.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-urllib3-1.7-2.fc19,python-requests-1.2.3-4.fc19
Comment 10 Fedora Update System 2013-08-28 22:15:45 EDT
python-requests-1.2.3-5.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-requests-1.2.3-5.fc19
Comment 11 Fedora Update System 2013-08-28 23:11:40 EDT
python-urllib3-1.7-3.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-urllib3-1.7-3.fc19
Comment 12 Jim Minter 2013-08-30 05:55:52 EDT
All works for me.  I'll report back if I encounter any issues with the new RPMs.  Thanks again.
Comment 13 Fedora Update System 2013-09-16 20:32:58 EDT
python-urllib3-1.7-3.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 14 Fedora Update System 2013-09-22 00:25:53 EDT
python-requests-1.2.3-5.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.