Page MenuHomePhabricator

Exception: JSON encoding failed.
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Exception: JSON encoding failed.
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Utils/PHPUtils.php(84)
#0 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(623): Wikimedia\Parsoid\Utils\PHPUtils::jsonEncode(array)
#1 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(804): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->exportJSConfigVars(Wikimedia\Parsoid\DOM\Compat\Document, Wikimedia\Parsoid\Config\Env)
#2 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(931): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->addMetaData(Wikimedia\Parsoid\Config\Env, Wikimedia\Parsoid\DOM\Compat\Document)
#3 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(948): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->doPostProcess(Wikimedia\Parsoid\DOM\Compat\Element)
#4 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/DOMPostProcessor.php(965): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->process(Wikimedia\Parsoid\DOM\Compat\Element)
#5 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/ParserPipeline.php(178): Wikimedia\Parsoid\Wt2Html\DOMPostProcessor->processChunkily(string, array)
#6 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Wt2Html/ParserPipelineFactory.php(307): Wikimedia\Parsoid\Wt2Html\ParserPipeline->parseChunkily(string, array)
#7 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Core/WikitextContentModelHandler.php(106): Wikimedia\Parsoid\Wt2Html\ParserPipelineFactory->parse(string)
#8 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Parsoid.php(166): Wikimedia\Parsoid\Core\WikitextContentModelHandler->toDOM(Wikimedia\Parsoid\Config\Env)
#9 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/src/Parsoid.php(198): Wikimedia\Parsoid\Parsoid->parseWikitext(MWParsoid\Config\PageConfig, array)
#10 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/extension/src/Rest/Handler/ParsoidHandler.php(588): Wikimedia\Parsoid\Parsoid->wikitext2html(MWParsoid\Config\PageConfig, array, NULL)
#11 /srv/mediawiki/php-1.37.0-wmf.18/vendor/wikimedia/parsoid/extension/src/Rest/Handler/PageHandler.php(88): MWParsoid\Rest\Handler\ParsoidHandler->wt2html(MWParsoid\Config\PageConfig, array)
#12 /srv/mediawiki/php-1.37.0-wmf.18/includes/Rest/Router.php(403): MWParsoid\Rest\Handler\PageHandler->execute()
#13 /srv/mediawiki/php-1.37.0-wmf.18/includes/Rest/Router.php(330): MediaWiki\Rest\Router->executeHandler(MWParsoid\Rest\Handler\PageHandler)
#14 /srv/mediawiki/php-1.37.0-wmf.18/includes/Rest/EntryPoint.php(165): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#15 /srv/mediawiki/php-1.37.0-wmf.18/includes/Rest/EntryPoint.php(130): MediaWiki\Rest\EntryPoint->execute()
#16 /srv/mediawiki/php-1.37.0-wmf.18/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#17 /srv/mediawiki/w/rest.php(3): require(string)
#18 {main}
Impact
Notes

Details

Request URL
https://tt.wikipedia.org/w/rest.php/tt.wikipedia.org/v3/page/pagebundle/%D0%9A%D0%B0%D0%BB%D1%8B%D0%BF%3A%D0%A2%D0%B8%D0%BF%D0%BE%D0%B2%D0%B0%D1%8F_%D1%81%D1%82%D0%B0%D1%82%D1%8C%D1%8F_%D0%BE_%D1%87%D0%B5%D0%BB%D0%BE%D0%B2%D0%B5%D0%BA%D0%B5/2301931

Event Timeline

Arlolra triaged this task as Medium priority.Sep 1 2021, 1:37 AM
Arlolra moved this task from Needs Triage to Bugs & Crashers on the Parsoid board.
Arlolra added a subscriber: Arlolra.

This started happening because of https://github.com/wikimedia/parsoid/commit/f2561c91b65183cc8b2929a838ace1dd379b0b59

Adding a bit of logging on scandium, I see,

> sudo -u www-data php /srv/mediawiki/multiversion/MWScript.php /srv/parsoid-testing/bin/parse.php --wiki=ttwiki --integrated --pageName "Калып:Типовая_статья_о_человеке" < /dev/null
array(1) {
  ["ScribuntoErrors"]=>
  array(1) {
    [0]=>
    string(431) "<p>Ошибка Lua в Модуль:Типовая_статья_о_человек? на строке 326: attempt to index local 'entity' (a nil value).</p><p>Трассировка вызовов:</p><ol class="scribunto-trace"><li><strong>:326</strong>: в функции «top»</li><li><strong>:507</strong>: в функции «chunk»</li><li><strong>mw.lua:525</strong>:&#160;?</li><li><strong>[C]</strong>:&#160;?</li></ol>"
  }
}
Exception from line 84 of /srv/parsoid-testing/src/Utils/PHPUtils.php: JSON encoding failed.

But the action api seems to be able to output that error ok,
https://tt.wikipedia.org/w/api.php?action=parse&page=%D0%9A%D0%B0%D0%BB%D1%8B%D0%BF:%D0%A2%D0%B8%D0%BF%D0%BE%D0%B2%D0%B0%D1%8F_%D1%81%D1%82%D0%B0%D1%82%D1%8C%D1%8F_%D0%BE_%D1%87%D0%B5%D0%BB%D0%BE%D0%B2%D0%B5%D0%BA%D0%B5&prop=jsconfigvars

We probably need to borrow some code from T287432

A bit more info here. I logged json_last_error() and it's from JSON_ERROR_UTF8. Looking at the action api output, I see a \ufffd.

Change 716074 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] [WIP] Cleanup jsconfigvars

https://gerrit.wikimedia.org/r/716074

Change 720404 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/extensions/Scribunto@master] Normalize the module name too

https://gerrit.wikimedia.org/r/720404

Change 720404 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] Apply utf normalize to lua module name in error messages

https://gerrit.wikimedia.org/r/720404

Change 716074 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Drop config vars if they fail to JSON strinfigy

https://gerrit.wikimedia.org/r/716074

Change 722416 had a related patch set uploaded (by Sbailey; author: Sbailey):

[mediawiki/vendor@master] Bump parsoid to 0.14.0-a19

https://gerrit.wikimedia.org/r/722416

Change 722416 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.14.0-a19

https://gerrit.wikimedia.org/r/722416