← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1306107] [NEW] mishandled error on key-pair generation

 

Public bug reported:

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.

** Affects: horizon
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1306107

Title:
  mishandled error on key-pair generation

Status in OpenStack Dashboard (Horizon):
  New

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1306107/+subscriptions


Follow ups

References