Last modified: 2014-10-11 14:48:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37300, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35300 - API returns invalid JSON despite HTTP status 200
API returns invalid JSON despite HTTP status 200
Status: UNCONFIRMED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.19
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 14261
  Show dependency treegraph
 
Reported: 2012-03-18 15:35 UTC by Rainer Rillke @commons.wikimedia
Modified: 2014-10-11 14:48 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Rainer Rillke @commons.wikimedia 2012-03-18 15:35:47 UTC
Since a while I enabled a semi-automated reporting of a very heavily used script on WikimediCommons.

The user has the possibility to press a button to post the error message to a list of those.

Now, after about 1 month there are 4 reported (this means that this occurs much more often) errors:

API request returned code 200 parsererror. Error code is SyntaxError: JSON.parse: Parsed string contains more than single value: <!DOCTY...

or

API request returned code 200 parsererror. Error code is SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

This means that jQuery received a 200 response and tried to build a JS-object for the presumed json-string and that failed.

Since we are using "secure techniques" (js objects) to build the query string, and the format-parameter is always set to json by a wrapper-method (all requests are handled by doAPICall), this problem only occurs when editing, I think the problem is at the server side.

If you would like to be up-to-date with those issues, just watch https://secure.wikimedia.org/wikipedia/commons/wiki/MediaWiki_talk:AjaxQuickDelete.js/auto-errors for new entries with "API request returned code" (I could make a separate page for server errors, if you want or send them with JSONP to a health-status-server. 
It's a page you can learn a lot from: E.g. "API request failed (hookaborted): The modification you tried to make was aborted by an extension hook" is a very bad error-message. User has to guess which hook of the the thousands.)
Comment 1 Dan Collins 2012-03-18 18:58:09 UTC
What request causes the API to return invalid JSON data, and what JSON data does it return?
Comment 2 Rainer Rillke @commons.wikimedia 2012-03-19 12:16:22 UTC
Maybe the post requests are somehow cut off or it is a specific Wikimedia issue. These errors seem to occur randomly and I have no clue how to reproduce.

One of the failed requests may have looked like:
POST to commons.wikimedia.org/w/api.php

Params:
action: edit
summary: Nominating for deletion
watchlist: preferences
title: File:Copa Airlines Colombia logo.jpg
token: //+
prependtext: {{delete|reason=Per [[:Commons:Deletion requests/File:Copa Airlines.jpg]] ~|subpage=File:Copa Airlines Colombia logo.jpg|year=2012|month=March|day=18}}
format: json

(action=edit&summary=Nominating+for+deletion&watchlist=preferences&title=File%3ACopa+Airlines+Colombia+logo.jpg&token=%2F%2F%2B&prependtext=%7B%7Bdelete%7Creason%3DPer+%5B%5B%3ACommons%3ADeletion+requests%2FFile%3ACopa+Airlines.jpg%5D%5D+~%7Csubpage%3DFile%3ACopa+Airlines+Colombia+logo.jpg%7Cyear%3D2012%7Cmonth%3DMarch%7Cday%3D18%7D%7D&format=json)

I know that the edit-token should be sent last. Will try to get it after the text. And, of course it is desirable having the format=json param first. Will make same changes and return if the issue persists.
Comment 3 Mark A. Hershberger 2012-03-19 20:49:56 UTC
(In reply to comment #0)
> If you would like to be up-to-date with those issues, just watch
> https://secure.wikimedia.org/wikipedia/commons/wiki/MediaWiki_talk:AjaxQuickDelete.js/auto-errors
> for new entries with "API request returned code"

Nice!  But, you do know you can just change "http" to "https" now, right?

That would give you:
 https://commons.wikimedia.org/wiki/MediaWiki_talk:AjaxQuickDelete.js/auto-errors

> It's a page you can learn a lot from: E.g. "API request failed (hookaborted):
> The modification you tried to make was aborted by an extension hook" is a very
> bad error-message. User has to guess which hook of the the thousands.)

See bug #22922 and bug #14261 comment #8  -- if you find others, please report them and mark #14261 for the tracker.
Comment 4 Rainer Rillke @commons.wikimedia 2012-03-20 16:11:45 UTC
Thanks for the pointers.

After I changed the order in which the object is built, this error seems to persist:

MediaWiki_talk%3AAjaxQuickDelete.js%2Fauto-errors&action=historysubmit&diff=68604416&oldid=68604084

(BTW, the user uses IE8 if this is of importance)

Of course browsers are free how they convert an object into a json-string but this error occurs too often that I would say it is a seldom loss of information somewhere between wikimedia and the client. I could try to improve the error-handler further to get the whole response-text & -headers which is difficult because it should not contain private/secret data (setCookies, tokens, ...).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links