mishandled error on key-pair generation

Bug #1306107 reported by Matthew D. Wood
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
In Progress
Undecided
Matthew D. Wood

Bug Description

While generating a key-pair, certain exceptions aren't being handled correctly in that they aren't being redirected.

This leaves us with a NameError on <keypair> after the exception was supposed to be handled.

[code]
class GenerateView(View):
    def get(self, request, keypair_name=None):
        try:
            keypair = api.nova.keypair_create(request, keypair_name)
        except Exception:
            redirect = reverse('horizon:project:access_and_security:index')
            exceptions.handle(self.request,
                              _('Unable to create key pair: %(exc)s'),
                              redirect=redirect)
            raise exceptions.Http302(redirect)

        response = http.HttpResponse(content_type='application/binary')
        response['Content-Disposition'] = \
                'attachment; filename=%s.pem' % slugify(keypair.name)
        response.write(keypair.private_key)
        response['Content-Length'] = str(len(response.content))
        return response
[/code]

I know that Unauthorized exceptions aren't redirected inside exceptions.handle, even if a redirect is specified. There may be other exceptions that slip through, I've been mystified by this type of thing in the past.

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/86649

Changed in horizon:
assignee: nobody → Matthew D. Wood (woodm1979)
status: New → In Progress
Revision history for this message
Julie Pichon (jpichon) wrote :

I think this is a duplicate of bug 1299126 (the fix certainly appears to be the same), even though the exception names mentioned seem to be different. Feel free to reopen if I am mistaken, thank you.

Revision history for this message
Matthew D. Wood (woodm1979) wrote :

@jpichon, I think you're right. I'll close out this bug and kill the review. Nice catch!

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.