launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14980
[Merge] lp:~wgrant/launchpad/bug-1100977 into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/bug-1100977 into lp:launchpad.
Commit message:
Fix gpghandler to cope with new SKS versions that sensibly return 404 rather than 500 for non-existent keys. Production SKS has been upgraded.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1100977 in Launchpad itself: "Unable to add gpg key to new account"
https://bugs.launchpad.net/launchpad/+bug/1100977
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1100977/+merge/144432
Fix gpghandler to cope with new SKS versions that sensibly return 404 rather than 500 for non-existent keys. Production SKS has been upgraded.
--
https://code.launchpad.net/~wgrant/launchpad/bug-1100977/+merge/144432
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1100977 into lp:launchpad.
=== modified file 'lib/lp/services/gpg/handler.py'
--- lib/lp/services/gpg/handler.py 2012-12-26 01:12:37 +0000
+++ lib/lp/services/gpg/handler.py 2013-01-23 04:29:24 +0000
@@ -487,11 +487,13 @@
# (and for the code in callsites), but we should be able to see
# if this problem occurs too often.
except urllib2.HTTPError as exc:
- # The key server behaves a bit odd when queried for non
- # existent keys: Instead of responding with a 404, it
- # returns a 500 error. But we can extract the fact that
- # the key is unknown by looking into the response's content.
- if exc.code == 500 and exc.fp is not None:
+ # Old versions of SKS return a 500 error when queried for a
+ # non-existent key. Production was upgraded in 2013/01, but
+ # let's leave this here for a while.
+ #
+ # We can extract the fact that the key is unknown by looking
+ # into the response's content.
+ if exc.code in (404, 500) and exc.fp is not None:
content = exc.fp.read()
no_key_message = 'Error handling request: No keys found'
if content.find(no_key_message) >= 0:
=== modified file 'lib/lp/testing/keyserver/web.py'
--- lib/lp/testing/keyserver/web.py 2012-06-29 08:40:05 +0000
+++ lib/lp/testing/keyserver/web.py 2013-01-23 04:29:24 +0000
@@ -153,9 +153,7 @@
'<pre>\n%s\n</pre>\n</html>') % (keyid, keyid, content)
return page
else:
- # No joke: our real-world keyserver returns a 500 error
- # if it does not know about a key with the given ID.
- request.setResponseCode(500)
+ request.setResponseCode(404)
return KEY_NOT_FOUND_BODY