BatchAction displays error messages twice

Bug #1733207 reported by Akihiro Motoki
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Akihiro Motoki

Bug Description

If action() in BatchAction displays an error message to describe some detail reason of a failure, a user will get multiple error messages: the detail error message and "Unable to <action> <object>".
This is because BatchAction handle() always tries to display error message. We need more smart error message handling.

On the other hand, if there is no need to display a detail error message in action() of individual BatchAction instance, try/except should not be used.

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

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

Changed in horizon:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Ying Zuo (yingzuo)
Changed in horizon:
milestone: queens-2 → queens-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/521381
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=faaa4aed8cd5547647e9a080239cd4f1f9fd4697
Submitter: Zuul
Branch: master

commit faaa4aed8cd5547647e9a080239cd4f1f9fd4697
Author: Akihiro Motoki <email address hidden>
Date: Sun Nov 19 17:27:44 2017 +0000

    Avoid sending error message twice in BatchAction

    BatchAction.handle() displays an aggregate error message
    if an exception is returned from individual action() method.
    If we don't need a detail error message, try/except is unnecessary.

    Note that a fix for a case where a detail error message is needed
    will be covered in the subsequent patches.

    Change-Id: I8037355b12e0756c6add5c5b9ba05a430155dfe5
    Partial-Bug: #1733207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/521382
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=a96e632bf5dbc95dc361c9a66d7485c8b19ba963
Submitter: Zuul
Branch: master

commit a96e632bf5dbc95dc361c9a66d7485c8b19ba963
Author: Akihiro Motoki <email address hidden>
Date: Sat Nov 11 18:43:46 2017 +0000

    Avoid duplicated message in Batch/DeleteAction

    Previously BatchAction.handle() automatically adds an error message
    when handle() method raises an exception. If some custom error message
    is shown in handle() method, two error messages will be shown.

    This commit allows a special handling for HandledException to
    BatchAction.handle(). In individual BatchAction instances,
    handle() method can now show a custom error message and raise an
    HandledException, and then BatchAction.handle() skips to show an
    error message for that. The reason of using HandledException is
    because the exception can be raised from exceptions.handle() function
    which is commonly used to handle exceptions.

    The common pattern in handle() would be:

     try:
        <do something>
     except Exception as e:
        # HandledException which wrapps the original exception will be raised.
        # HandledException will be caught by BatchAction.handle().
        exceptions.handle(request, msg, escalate=True)

    To make it easier to use the pattern, a new decorator
    horizon.tables.actions.handle_exception_with_detail_message is introduced.

    Partial-Bug: #1733207
    Change-Id: I4bb0f61c7b63ea6ecd2e30c03eddecee62ff9b13

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/521384
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=3e8088b80067c480b3b3aba0a8d2caf02dfb5672
Submitter: Zuul
Branch: master

commit 3e8088b80067c480b3b3aba0a8d2caf02dfb5672
Author: Akihiro Motoki <email address hidden>
Date: Sun Nov 19 20:46:44 2017 +0000

    Improve exception message in network related Batch/DeleteAction

    DeleteActiona and BatchAction in the network, subnet and router tables
    are improved using handle_exception_with_detail_message decorator.

    There is no need to have separate delete action in the admin network
    and subnet tables now, so they are merged into the corresponding delete
    actions in the project tables.

    Change-Id: I976e4e6ed8e9c1430f82ac362c080853744b5d07
    Closes-Bug: #1733207

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 13.0.0.0rc1

This issue was fixed in the openstack/horizon 13.0.0.0rc1 release candidate.

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.