Local variable referenced before assignment in logintoken GPG key validation

Bug #150591 reported by Diogo Matsubara
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Jonathan Lange

Bug Description

The method _getGPGKey() in ValidateGPGKeyView have the following try/except:

        try:
            key = gpghandler.retrieveKey(fingerprint)
        except GPGKeyNotFoundError:
            self.addError(_(
                'Launchpad could not import this OpenPGP key, because %s. '
                'Check that you published it correctly in the global key ring '
                '(using <kbd>gpg --send-keys KEY</kbd>) and that you '
                'entered the fingerprint correctly (as produced by <kbd>'
                'gpg --fingerprint YOU</kdb>). Try later or '
                '<a href="%s/+editpgpkeys">cancel your request</a>.'
                % (key, person_url)))
            return None

When retrieveKey() raises a GPGKeyNotFoundError, the 'key' variable is unassigned causing OOPS-644C894 UnboundLocalError local variable 'key' referenced before assignment

The error message needs to be fixed as well. Currently it doesn't make much sense.

Related branches

Revision history for this message
Diogo Matsubara (matsubara) wrote :

More recent occurance: OOPS-823EA59

Changed in launchpad:
status: New → Confirmed
Jonathan Lange (jml)
Changed in launchpad-foundations:
assignee: nobody → Jonathan Lange (jml)
importance: Undecided → High
milestone: none → 10.03
status: Confirmed → In Progress
Gary Poster (gary)
Changed in launchpad-foundations:
status: In Progress → Fix Committed
Jonathan Lange (jml)
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
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.