Client exposes internal requests library exception

Bug #1406586 reported by andersonvom
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Wishlist
Jason Dunsmore

Bug Description

Novaclient expects the requests library to always be able to get a response back and doesn't handle other cases where it might raise an exception even before the request is completed (e.g. ConnectionError).

These exceptions should be captured and properly converted to some native novaclient exception.

melanie witt (melwitt)
Changed in python-novaclient:
importance: Undecided → Medium
status: New → Confirmed
Changed in python-novaclient:
assignee: nobody → jelly (coding1314)
Revision history for this message
Kuo-tung Kao (jelly) (coding1314) wrote :

There are four exceptions in requests library. HTTPError, Timeout, ConnectionError, TooManyRedirects . I map requests.ConnectionError to exceptions.ConnectionRefused(), requests.Timeout to exceptions.ClientException(408, str(e)). What about HTTPError and TooManyRedirects? Could anyone give me suggestion? Thank you.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/189540

Changed in python-novaclient:
status: Confirmed → In Progress
Revision history for this message
Kevin L. Mitchell (klmitch) wrote : Re: Client exposes internal requests llibrary exception

I don't understand this bug report. It doesn't make sense to me that we should translate an exception; the typical Python philosophy is to allow foreign exceptions to bubble up. Why shouldn't we do that?

Revision history for this message
melanie witt (melwitt) wrote :

Kevin, I wasn't sure. The scenario I imagine is someone using the novaclient python API and writing code to handle, for example, "connection refused." Let's say they want to retry a request if they get "connection refused." Currently, they would not only import novaclient.client, but also need to import requests to catch "connection refused" and retry. If we translated exceptions, only novaclient modules would be imported in their program.

That said, I'm not sure what the usual convention is, so I'll switch this to Opinion/Wishlist.

Changed in python-novaclient:
importance: Medium → Wishlist
Revision history for this message
melanie witt (melwitt) wrote :

Another thing I forgot to mention is, if for some reason novaclient switched to a different underlying library than requests, the person's code would continue to work because they handle novaclient exceptions, not requests exceptions.

Revision history for this message
andersonvom (andersonvom) wrote :

The reason I submitted the bug report was precisely the one melanie described last: using requests is something that novaclient is doing right now, but it's an implementation detail. The user shouldn't have to know or care about the fact that requests is used, so properly wrapping/converting them would be ideal, IMO.

Revision history for this message
Kevin L. Mitchell (klmitch) wrote :

Hmmm, OK; let me think about this one for a while…

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-novaclient (master)

Change abandoned by Kuo-tung Kao (<email address hidden>) on branch: master
Review: https://review.openstack.org/189540
Reason: Since it seems that no one will give the patch +2, working on the patch is meaningless.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/235558

Changed in python-novaclient:
assignee: jelly (coding1314) → Jason Dunsmore (jasondunsmore)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/235558
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=2961e82bfa6e375ac3c17933fac532ed316ac976
Submitter: Jenkins
Branch: master

commit 2961e82bfa6e375ac3c17933fac532ed316ac976
Author: Jason Dunsmore <email address hidden>
Date: Thu Oct 15 12:00:39 2015 -0500

    Do not expose exceptions from requests library

    Novaclient expects the requests library to always be able to get a
    response back and doesn't handle other cases where it might raise
    an exception even before the request is completed (e.g.
    ConnectionError).

    These exceptions should be captured and properly converted to some
    native novaclient exception.

    Change-Id: Iec7247b715c38c29910b30e76413cead4e951a37
    Co-Authored-By: Kuo-tung Kao <email address hidden>
    Closes-Bug: #1406586

Changed in python-novaclient:
status: In Progress → Fix Committed
Changed in python-novaclient:
milestone: none → 2.33.0
status: Fix Committed → Fix Released
Matt Riedemann (mriedem)
summary: - Client exposes internal requests llibrary exception
+ Client exposes internal requests library exception
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/240023

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-novaclient (master)

Change abandoned by Jason Dunsmore (<email address hidden>) on branch: master
Review: https://review.openstack.org/240023
Reason: Thanks for the feedback

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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