Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid JSON error #22

Open
misaochan opened this issue Sep 18, 2020 · 4 comments
Open

Fix invalid JSON error #22

misaochan opened this issue Sep 18, 2020 · 4 comments
Labels

Comments

@misaochan
Copy link
Member

Currently this API returns invalid JSON, leading to display of wrong achievement count in the app. See commons-app/apps-android-commons#3900 for more details.

@misaochan misaochan added the bug label Sep 18, 2020
@nicolas-raoul
Copy link
Member

Summary of the problem:

https://commons-android-app.toolforge.org/tool-commons-android-app/feedback.py?user=Syced returns erroneous JSON:

Content-type: application/json
()
{"status": "ok", "uniqueUsedImages": 645, "articlesUsingImages": 3334, "database": "commonswiki", "deletedUploads": 38, "featuredImages": {"Quality_images": 0, "Featured_pictures_on_Wikimedia_Commons": 0}, "labs": false, "thanksReceived": 23, "user": "Syced", "imagesEditedBySomeoneElse": 1688}

The script should return correct JSON like https://commons-android-app.toolforge.org/tool-commons-android-app/feedback_test.py?user=Syced shows:

{"status": "ok", "uniqueUsedImages": 645, "articlesUsingImages": 3334, "database": "commonswiki", "deletedUploads": 38, "featuredImages": {"Quality_images": 0, "Featured_pictures_on_Wikimedia_Commons": 0}, "labs": false, "thanksReceived": 23, "user": "Syced", "imagesEditedBySomeoneElse": 1688}

@urbanecm
Copy link
Collaborator

urbanecmbot.toolforge.org-powered copy of the script now returns a valid JSON:

urbanecm@tools-sgebastion-07  ~
$ curl https://urbanecmbot.toolforge.org/commonsmisc/feedback.py?user=Syced
{"status": "ok", "uniqueUsedImages": 662, "articlesUsingImages": 3368, "database": "commonswiki", "deletedUploads": 45, "featuredImages": {"Quality_images": 0, "Featured_pictures_on_Wikimedia_Commons": 0}, "labs": false, "thanksReceived": 24, "user": "Syced", "imagesEditedBySomeoneElse": 1735}
urbanecm@tools-sgebastion-07  ~
$

I apologize for the delay here – if you do need me urgently, please feel free to ping me (either via mail, or IRC), I might miss notifications from GitHub :/.

@urbanecm
Copy link
Collaborator

(didn't intend to close this, just wanted to reference the commit; reopening)

@urbanecm urbanecm reopened this Apr 18, 2021
@urbanecm
Copy link
Collaborator

urbanecm commented Apr 18, 2021

For the record, this is my new .lighttpd.conf which fixes this:

tools.urbanecmbot@tools-sgebastion-07 ~/commonsmisc
$ cat ~/.lighttpd.conf
index-file.names += ("index.py")
setenv.add-response-header += ( "Access-Control-Allow-Origin" => "*" )
accesslog.filename = "/data/project/urbanecmbot/access.log"
$HTTP["url"] =~ "^" {
            cgi.assign = (".py" => "/usr/bin/python3")
}
tools.urbanecmbot@tools-sgebastion-07 ~/commonsmisc
$

The key part is at the end, it previously said "^/urbanecmbot", since the tool was in a subdirectory. That changed...recently, and the part no longer took effect. I'd fix it in the other tool as well, but it seems I'm not a maintainer there, so I'll leave that to someone else.

@urbanecm urbanecm reopened this Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants