ClientException __str__ shows wrong message for HTTP errors

Bug #1284585 reported by Tihomir Trifonov
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-swiftclient
Fix Released
Undecided
Unassigned

Bug Description

2014-02-25 09:40:22.874 | 2014-02-25 09:40:09,765 Account GET failed: http://127.0.0.1:8080:8080/v1/AUTH_7c76c1068bde48a9b082c002b5dca032?format=json 503 Internal Server Error [first 60 chars of response] <html><h1>Service Unavailable</h1><p>The server is currently

in ClientException.__str__ we have:

    def __str__(self):
        a = self.msg
        b = ''
        if self.http_scheme:
            b += '%s://' % self.http_scheme
        if self.http_host:
            b += self.http_host
        if self.http_port:
            b += ':%s' % self.http_port

in client.py we have:

        self.parsed_url = urlparse(url)
        self.host = self.parsed_url.netloc
        self.port = self.parsed_url.port

and then

        raise ClientException('Account GET failed', http_scheme=parsed.scheme,
                              http_host=conn.host, http_port=conn.port,
                              http_path=parsed.path, http_query=qs,
                              http_status=resp.status, http_reason=resp.reason,
                              http_response_content=body)

The problem is that conn.host contains netloc from url, which already contains the :port part, so passing and appending self.http_port to error message is not needed.

Revision history for this message
Zack M. Davis (zdavis) wrote :

This is fixed in python-swiftclient 2.1.0 (in commit 2e1a5b7e https://github.com/openstack/python-swiftclient/commit/2e1a5b7e):

(swiftclient21)vagrant@saio:~/swiftclient21$ swift --version
swift 2.1.0
(swiftclient21)vagrant@saio:~/swiftclient21$ swift download fakecontainer fakeobject
Auth GET failed: http://saio:8080/auth/v1.0 401 Unauthorized

Contrast the old behavior:

(swiftclient203)vagrant@saio:~/swiftclient203$ swift --version
swift 2.0.3
(swiftclient203)vagrant@saio:~/swiftclient203$ swift download fakecontainer fakeobject
Auth GET failed: http://saio:8080:8080/auth/v1.0 401 Unauthorized

Although it does occur to me that this could probably have been fixed in a more robust way by changing ClientException and not just the calls to it: as it stands, if some other, future caller passes both the http_host and http_port arguments to the ClientException constructor, the same bug will crop up again.

Revision history for this message
Yugang LIU (liuyug) wrote :

I have upgraded to swift 2.1.0. It's Ok. Thank you.

Revision history for this message
Mrz001 (mrz001com) wrote :

Maybe it should be:

self.host = self.parsed_url.netloc.split(":")[0]

Zack M. Davis (zdavis)
Changed in python-swiftclient:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.