Page MenuHomePhabricator

VE/Parsoid/SyntaxHighlight - Error Failed to parse the JSON response for Extension Parse
Closed, ResolvedPublic0 Estimated Story Points


Using mediawiki 1.27 with matching Visual Editor and parsoid service. To replicate my environment exactly you can run the following on redhat/debian (tested exclusively on centos 7.2, ubuntu 14.04. Should work on any though):

Starting and Stopping Services
docker stop CONTAINER_NAME; docker start CONTAINER_NAME

Accessing Daemon Logs
docker logs [ -f ] CONTAINER_NAME

Accessing a Shell
docker exec -ti CONTAINER_NAME /bin/sh

Managing the Database
docker exec -ti mariadb mysql

You'll goto the ip of your vm or vps or dedicated whichever type of system you use and be greeted with a media wiki start install page. Do the install as you would any base install (no need to download localsettings in this one). Edit the main page with the visual editor and insert a code block.

On your virtual instance follow the parsoid log:
docker logs [-f] parsoid

It should return something like:

[error/extension][wiki$0/Main_Page] Error Failed to parse the JSON response for Extension Parse  parsing extension token:  {"type":"SelfclosingTagTk","name":"extension","attribs":[{"k":"typeof","v":"mw:Extension"},{"k":"name","v":"syntaxhighlight"},{"k":"about","v":"#mwt1"},{"k":"source","v":"<syntaxhighlight lang=\"bash\">\necho test\n</syntaxhighlight>"},{"k":"options","v":[{"k":"lang","v":"bash","vsrc":"bash"}]}],"dataAttribs":{"tsr":[0,58],"stx":"html","src":"<syntaxhighlight lang=\"bash\">\necho test\n</syntaxhighlight>","tagWidths":[29,18]}}
ParserError: Failed to parse the JSON response for Extension Parse
    at PHPParseRequest.ApiRequest._handleBody (/parsoid/lib/mw/ApiRequest.js:457:11)
    at PHPParseRequest.ApiRequest._requestCB (/parsoid/lib/mw/ApiRequest.js:415:8)
    at Request.self.callback (/parsoid/node_modules/request/request.js:200:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/parsoid/node_modules/request/request.js:1067:10)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/parsoid/node_modules/request/request.js:988:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:973:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[info][wiki$0/Main_Page] completed parsing in 481 ms

Event Timeline

Just wondering if there is any traction on this? I hope this question doesn't come across as overbearing. Idk if the code block thing is experimental and not even function or whether this sort of report is even welcome. I know it's all docker, but both node and php were built from the latest source images. I had tried the latest stable node release, but got the same error. If there are any questions for me, please let me know.

If you edit a wikitext page and put the same syntaxhighlight tag on it (<syntaxhighlight lang="bash">echo test</syntaxhighlight>), does it work fine? If Parsoid can't parse the JSON from the MediaWiki API, perhaps it doesn't produce any JSON at all – that can happen in case of PHP fatal errors.

I agree with @matmarex -- my guess would be that the MediaWiki API isn't returning anything at all. We could perhaps improve Parsoid's logging in that case, I suppose. But the root cause is probably a misconfiguration of the syntaxhighlight extension in the docker image.

You guys are right. I did the syntax tags in the regular editor and got the descriptive: "Exception encountered, of type "Error"" even with php debug and display errors on. After some additional reading it seems that you have to not only composer install in the base dir of mediawiki, but also in the highlighter at the very least. This resolved my error. Thank you guys.