Comment 150 for bug 1776504

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

Reviewed: https://review.openstack.org/609796
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=9b052e4c059893791dd7adc4aa32d40ac098e788
Submitter: Zuul
Branch: master

commit 9b052e4c059893791dd7adc4aa32d40ac098e788
Author: Morgan Fainberg <email address hidden>
Date: Thu Oct 11 12:32:59 2018 -0700

    Register exceptions with a Flask Error Handler

    Exceptions are now handled in the Flask APP instead of in the
    legacy webob Application code (at this point that code was living
    in the URL Normalizing Middleware). All Keystone API exceptions
    (derived from keystone.exception.Error) are automatically
    registered on definition with the
    keystone.exception.KEYSTONE_API_EXCEPTIONS set. This set is
    processed once the app is created in keystone.server.application
    to the flask-friendly handler.

    TypeError and generic Exception are registered to an explicit
    error handler that converts TypeError to ValidationError (BAD_REQUEST)
    and all other Exceptions to UnexpectedError (INTERNAL SERVER ERROR).
    These exceptions are then emitted in a "jsonify-ed" manner to the
    client.

    Two other minor changes were required:

    * Unenforced API decorator had it's core functionality split into
      a dedicated function that can be called in the case of an error
      being raised in a "before_request" function (such as validation
      in the JSON Body before request func.

    * The JSON Body before request func now explicitly sets the
      api to "unenforced_ok" if it is raising an exception. This
      prevents the flask "was this API enforced" assertion from failing
      because @unenforced_api was never run (the ValidationError was
      raised prior to the resource's method being called).

    Change-Id: I0d0ef6a774eb86b4769238ed34d7703232ce86c3
    Partial-Bug: #1776504