Don't disguise important errors with HTTPExceptionDisguise

Bug #1221669 reported by mouadino
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Triaged
Low
Kent Wang

Bug Description

Hi,

The https://github.com/openstack/heat/blob/master/heat/api/openstack/v1/stacks.py contain a lot of "raise exc. HTTPBadRequest" which hold very useful information for api user to know what went wrong with there request, but sadly in the WSGI resource defined here https://github.com/openstack/heat/blob/master/heat/common/wsgi.py all this useful messages will be changed to HTTPExceptionDisguise, which then will be sent to user as 500 code error with an awful traceback. The related code that do that:

        ...
     except webob.exc.HTTPException as err:
            if isinstance(err, (webob.exc.HTTPOk, webob.exc.HTTPRedirection)):
                # Some HTTPException are actually not errors, they are
                # responses ready to be sent back to the users, so we don't
                # error log, disguise or translate those
                raise
            logging.error(_("Returning %(code)s to user: %(explanation)s"),
                          {'code': err.code, 'explanation': err.explanation})
            http_exc = translate_exception(err, request.best_match_language())
            raise exception.HTTPExceptionDisguise(http_exc)

My suggestion is to use return with exc. HTTPBadRequest instead of raise in https://github.com/openstack/heat/blob/master/heat/api/openstack/v1/stacks.py, this way the wsgi resource will not change them and user will receive the useful message and the correct http error code i.e. 400.

If this bug is confirmed i will be glad to send you the patch that i have created to fix this.

Thanks for your time.

Revision history for this message
Steven Hardy (shardy) wrote :

If you have a patch, please either attach it or propose it via gerrit, it's pointless to say you have a patch and not provide us with visibility of it IMHO, thanks!

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

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

Changed in heat:
assignee: nobody → mouadino (mouadino)
status: New → In Progress
Revision history for this message
mouadino (mouadino) wrote :

The suggestion that i have proposed didn't hold for much long, i have already hit some cases where it will not work.

But i have another patch in mind that may ease up the pain a bit, but i am still trying to figure out how to make api return correct code status and what is the purpose of wrapping all errors with HTTPExceptionDisguise because i don't think it's a good idea i.e. REST API is broken.

https://review.openstack.org/#/c/45857/ (Patch in question)

Thanks,

Revision history for this message
Angus Salkeld (asalkeld) wrote :

The reviews are not visible, so I am setting to unassigned so someone else can try and fix.

Changed in heat:
status: In Progress → Triaged
importance: Undecided → Low
assignee: mouadino (mouadino) → nobody
Kent Wang (k.wang)
Changed in heat:
assignee: nobody → Kent Wang (k.wang)
Rico Lin (rico-lin)
Changed in heat:
milestone: none → no-priority-tag-bugs
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.