Last modified: 2013-04-22 16:15:47 UTC
I wanted to upload some images and I noticed the function to check for duplicate files stopped working. When I do a manual query at https://commons.wikimedia.org/w/api.php?action=query&aisha1=4E2E2F6EC0CB4964875F2A045DB8531BC8E5ADD7&list=allimages&format=json I get: { "servedby": "srv299", "error": { "code": "aiinvalidsha1hash", "info": "The SHA1 hash provided is not valid" } } 4E2E2F6EC0CB4964875F2A045DB8531BC8E5ADD7 is a valid sha1 hash generated by the follow python code: hashObject = hashlib.sha1() hashObject.update(self.downloadPhoto().getvalue()) base64.b16encode(hashObject.digest()) This used to work. Last successful upload was on the 14th of November (https://commons.wikimedia.org/wiki/Special:ListFiles/BotMultichillT). I looked at https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=history;f=includes/api/ApiQueryAllImages.php;h=e6a019460764383891284366d237a0a7c7043138;hb=HEAD and my assumption is that https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=commitdiff;h=529db96cdc31c5a1870ee0df623f21912a73c9aa caused this.
Are you sure it is a valid SHA1 hash? Retrieving the SHA1 with http://commons.wikimedia.org/w/api.php?action=query&list=allimages&aiprop=sha1&aifrom=A and then calling again with the same SHA1 http://commons.wikimedia.org/w/api.php?action=query&list=allimages&aisha1= (SHA appended here) works for me.
Yes, it's valid. Looks like the uppercase/lowercase is an issue here. Try taking a hash and change one letter to uppercase, it will give an error. As this is base16 encoded, bot lowercase and uppercase are correct and should be accepted.
This was broken in change Ic980fd71; apparently no one noticed that both users of validateSha1Hash pass the hash through wfBaseConvert which accepts both lower and uppercase letters. Gerrit change I70493519 should fix it. In the mean time, a workaround is to use lowercase letters in the hash.
Yes, already applied the workaround to Pywikipedia, see http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10802
Resolving bug. Gerrit change #39010 has been successfully merged into the git repository. Thanks Brad!