Last modified: 2014-10-11 14:48:09 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.)
What request causes the API to return invalid JSON data, and what JSON data does it return?
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.
(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.
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, ...).