From 301569b81d46e7896f78296a5775f69cf7f8935f Mon Sep 17 00:00:00 2001 From: woodm1979 Date: Tue, 8 Apr 2014 10:38:52 -0600 Subject: [PATCH] Fix KeyError in router:AddInterface error handle Under some circumstances the exception handling on adding an interface to a router will produce a KeyError. The exception happens in openstack_dashboard/dashboards/project/routers/ports/forms.py in AddInterface.populate_subnet_id_choices. In the exception handling code, a reverse() is called an argument of request.REQUEST['router_id'] which doesn't always exist. The fix is quite simple: try to look for it in the initial form data as well, and if 'router_id' is in neither location, fall-back to the index page. Change-Id: I74eaf8cd024d2929fed3d4e00b644e5850e2d5b3 Closes-Bug: 1304533 --- .../dashboards/project/routers/ports/forms.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/dashboards/project/routers/ports/forms.py b/openstack_dashboard/dashboards/project/routers/ports/forms.py index c783d5306f..6252466b12 100644 --- a/openstack_dashboard/dashboards/project/routers/ports/forms.py +++ b/openstack_dashboard/dashboards/project/routers/ports/forms.py @@ -56,8 +56,12 @@ class AddInterface(forms.SelfHandlingForm): msg = _('Failed to get network list %s') % e.message LOG.info(msg) messages.error(request, msg) - redirect = reverse(self.failure_url, - args=[request.REQUEST['router_id']]) + router_id = request.REQUEST.get('router_id', + self.initial.get('router_id')) + if router_id: + redirect = reverse(self.failure_url, args=[router_id]) + else: + redirect = reverse('horizon:project:routers:index') exceptions.handle(request, msg, redirect=redirect) return