libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (LIBCLOUD-901) 4xx and 5xx HTTP status codes are silently masked as 200
Date Thu, 09 Mar 2017 07:04:38 GMT


ASF GitHub Bot commented on LIBCLOUD-901:

GitHub user richardxia opened a pull request:

    LIBCLOUD-901 Correctly wrap requests library Responses with 4xx/5xx status codes

    ## Correctly wrap requests library Responses with 4xx/5xx status codes
    ### Description
    This fixes the constructor of `RawResponse` to explicitly check if `response is not None`.
This is necessary because the requests library overloads the `__nonzero__`/`__bool__` methods
on the `Response` object to return False if a 4xx or 5xx status code is returned. This [has
been fixed]( in the 3.0 branch of requests,
but that version hasn't been released yet.
    ### Status
    done, ready for review
    ### Checklist (tick everything that applies)
    I haven't checked any of these because all I did was make a 10 character change.
    - [ ] [Code linting](
(required, can be done after the PR checks)
    - [ ] Documentation
    - [ ] [Tests](
    - [ ] [ICLA](
(required for bigger changes)

You can merge this pull request into a Git repository by running:

    $ git pull LIBCLOUD-901-fix-requests-response-check

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1006
commit 9db64851cbced4c8f8249931b619b414128373be
Author: Richard Xia <>
Date:   2017-03-09T06:41:04Z

    [LIBCLOUD-901] Explicitly check if response is None.
    In versions of requests < 3.0, the __bool__/__nonzero__ method on RawResponse is
    overloaded to return False if the status code is 4xx or 5xx.


> 4xx and 5xx HTTP status codes are silently masked as 200
> --------------------------------------------------------
>                 Key: LIBCLOUD-901
>                 URL:
>             Project: Libcloud
>          Issue Type: Bug
>            Reporter: Richard Xia
> I'm seeing this on the latest trunk as well as v2.0.0rc1-tentative. When I try to upload
an object to AWS S3 using the {{upload_object_via_stream}} method and there is an error (I'll
create a separate ticket for that, which I've also determined the cause of), {{libcloud}}
will ignore the 5xx error response from {{requests}} and set the status to the default of
> The reason this occurs is because the constructor of {{RawResponse}} has an optional
argument {{response}} which has a default value of {{None}}. The body of the constructor checks
[{{if response}}|]
to check if a response was passed into the constructor, but it turns out that the {{requests}}
library [overloads the {{__nonzero__}}/{{__bool__}} methods|]
to return {{False}} if the response status code is 4xx or 5xx. This [has been fixed|]
in the 3.0 branch of {{requests}}, but version 3.0 hasn't been released yet, so this currently
affects all versions of requests.
> I will submit a pull request with the small change to fix this.

This message was sent by Atlassian JIRA

View raw message