Closed domdomegg closed 5 years ago
Pinging @urbanecm
Copying from server logs:
Traceback (most recent call last):
File "/data/project/urbanecmbot/public_html//commonsmisc/feedback.py", line 132, in <module>
print(jsonify(response))
File "/data/project/urbanecmbot/public_html//commonsmisc/feedback.py", line 12, in jsonify
return json.dumps(response)
File "/usr/lib/python3.5/json/__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
TypeError: keys must be a string
I've copied feedback.py to test.py and adapted it to use first argument passed on the command line instead of the user get parameter (which isn't easily passable from the commandline). Then I did the per-user testing @domdomegg did using the API, to confirm the error quoted above indeed comes from @domdomegg 's request (error.log seemingly doesn't log the url, just the traceback - an issue, but story for another task I guess).
tools.urbanecmbot@tools-sgebastion-07 ~/commonsmisc
$ python3 test.py Domdomegg
Content-type: application/json
Printed without jsonify()
{'status': 'ok', 'uniqueUsedImages': 111, 'articlesUsingImages': 2741, 'deletedUploads': 19, 'thanksReceived': 13, 'user': 'Domdomegg', 'featuredImages': {'Quality_images': 0, b'Quality_images': 2, 'Featured_pictures_on_Wikimedia_Commons': 0}, 'imagesEditedBySomeoneElse': 318}
Traceback (most recent call last):
File "test.py", line 108, in <module>
print(jsonify(response))
File "test.py", line 12, in jsonify
return json.dumps(response)
File "/usr/lib/python3.5/json/__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
TypeError: keys must be a string
tools.urbanecmbot@tools-sgebastion-07 ~/commonsmisc
$ python3 test.py Misaochan
Content-type: application/json
Printed without jsonify()
{'status': 'ok', 'deletedUploads': 76, 'user': 'Misaochan', 'imagesEditedBySomeoneElse': 231, 'articlesUsingImages': 83, 'thanksReceived': 4, 'uniqueUsedImages': 73, 'featuredImages': {'Quality_images': 0, 'Featured_pictures_on_Wikimedia_Commons': 0}}
{"status": "ok", "deletedUploads": 76, "user": "Misaochan", "imagesEditedBySomeoneElse": 231, "articlesUsingImages": 83, "thanksReceived": 4, "uniqueUsedImages": 73, "featuredImages": {"Quality_images": 0, "Featured_pictures_on_Wikimedia_Commons": 0}}
The interesting part is that for @domdomegg, there is Quality_images
and b'Quality images'
in the response
variable, which certainly isn't correct. It matches the keys must be a string TypeError. That was caused by missing .decode('utf-8') statement in feedback.py. I've added it in commons-app/commonsmisc@63999a38b6c33f0e3fbe27a002bc4566e6d56407, API looks to be working again:
tools.urbanecmbot@tools-sgebastion-07 ~/commonsmisc
$ curl 'https://tools.wmflabs.org/urbanecmbot/commonsmisc/feedback.py?user=Domdomegg'
{"thanksReceived": 13, "user": "Domdomegg", "imagesEditedBySomeoneElse": 318, "deletedUploads": 19, "featuredImages": {"Featured_pictures_on_Wikimedia_Commons": 0, "Quality_images": 2}, "uniqueUsedImages": 111, "articlesUsingImages": 2741, "status": "ok"}
Since I lack permissions to close this issue, please @domdomegg, check this and close if it works! Thanks!
Perfect, thanks for the quick fix :)
Summary:
Achievements fails to load for me, gives snackbar error "Something went wrong, We could not fetch your achievements".
Steps to reproduce:
How can we reproduce the issue?
See blank API response is particular to me: https://tools.wmflabs.org/urbanecmbot/commonsmisc/feedback.py?user=Domdomegg
Example correct API response (misaochan): https://tools.wmflabs.org/urbanecmbot/commonsmisc/feedback.py?user=Misaochan
System logs:
Device and Android version:
2.10.1-debug-master~44c18ac23
, emulator API level 28Screen-shots: