libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
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

    [ https://issues.apache.org/jira/browse/LIBCLOUD-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15902587#comment-15902587
] 

ASF GitHub Bot commented on LIBCLOUD-901:
-----------------------------------------

GitHub user richardxia opened a pull request:

    https://github.com/apache/libcloud/pull/1006

    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](https://github.com/kennethreitz/requests/pull/2587) 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](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
(required, can be done after the PR checks)
    - [ ] Documentation
    - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
    - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
(required for bigger changes)


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

    $ git pull https://github.com/richardxia/libcloud LIBCLOUD-901-fix-requests-response-check

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

    https://github.com/apache/libcloud/pull/1006.patch

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 <rxia@sifive.com>
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: https://issues.apache.org/jira/browse/LIBCLOUD-901
>             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
200.
> 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}}|https://github.com/apache/libcloud/blob/516018d050a5470afe4a07d33d1fcb26d0e1df18/libcloud/common/base.py#L285]
to check if a response was passed into the constructor, but it turns out that the {{requests}}
library [overloads the {{__nonzero__}}/{{__bool__}} methods|https://github.com/kennethreitz/requests/issues/2002]
to return {{False}} if the response status code is 4xx or 5xx. This [has been fixed|https://github.com/kennethreitz/requests/pull/2587]
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
(v6.3.15#6346)

Mime
View raw message