[go: up one dir, main page]

Page MenuHomePhabricator

LogicException: HTML generation was requested, but JsonContent that passed to ContentRenderer::getParserOutput() returns a ParserOutput with no text set.
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   LogicException: HTML generation was requested, but JsonContent that passed to ContentRenderer::getParserOutput() returns a ParserOutput with no text set.
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.6/includes/Revision/RenderedRevision.php(240)
#0 /srv/mediawiki/php-1.40.0-wmf.6/includes/Revision/RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array)
#1 /srv/mediawiki/php-1.40.0-wmf.6/includes/Revision/RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)
#2 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#3 /srv/mediawiki/php-1.40.0-wmf.6/includes/Revision/RenderedRevision.php(199): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)
#4 /srv/mediawiki/php-1.40.0-wmf.6/includes/Storage/DerivedPageDataUpdater.php(1438): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#5 /srv/mediawiki/php-1.40.0-wmf.6/includes/Storage/PageEditStash.php(167): MediaWiki\Storage\DerivedPageDataUpdater->getCanonicalParserOutput()
#6 /srv/mediawiki/php-1.40.0-wmf.6/includes/api/ApiStashEdit.php(198): MediaWiki\Storage\PageEditStash->parseAndCache(MediaWiki\Storage\PageUpdater, JsonContent, User, string)
#7 /srv/mediawiki/php-1.40.0-wmf.6/includes/api/ApiMain.php(1900): ApiStashEdit->execute()
#8 /srv/mediawiki/php-1.40.0-wmf.6/includes/api/ApiMain.php(875): ApiMain->executeAction()
#9 /srv/mediawiki/php-1.40.0-wmf.6/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#10 /srv/mediawiki/php-1.40.0-wmf.6/api.php(90): ApiMain->execute()
#11 /srv/mediawiki/php-1.40.0-wmf.6/api.php(45): wfApiMain()
#12 /srv/mediawiki/w/api.php(3): require(string)
#13 {main}
Notes
  • About six per day over the past 30 days
  • Seems to happen when json edits are made via the action api

Details

Request URL
https://test.wikipedia.org/w/api.php

Event Timeline

Tagged Parsoid although I don't think that's quite correct, but does anyone from that team have a good idea for a home for this (please :))?

@daniel, do you have any thoughts on what component(s) this should be associated with? We don't think it's Parsoid-related.

This seems related to MCR and the Content pipeline, so I'm hoping @daniel has some insight. I touched this code a number of weeks ago to tweak the ParserOptions set when rendering JSON, but the timing's not really right for this to be my fault. If we've got a precise start time for these logs, perhaps we can git-bisect.

Seems to happen when json edits are made via the action api

The error is coming from the stashedit API, which is an internal API used by the EditPage. So it rather seems this happens when editing JSON content manually in the UI.

I reproduces this locally. It will happen when stashedit is triggered on JSON content that is not syntactically valid.

JsonContenthandler has the following code:

		if ( $cpoParams->getGenerateHtml() && $content->isValid() ) {
			$parserOutput->setText( $content->rootValueTable( $content->getData()->getValue() ) );
			$parserOutput->addModuleStyles( [ 'mediawiki.content.json' ] );
		} else {
			$parserOutput->setText( null );
		}

So, if isValid() returns false, the ParserOutput object will not contain text.

I beleive this is a violation of the contract of fillParserOutput: if HTML generation is request, the resulting ParserOutput must contain HTML (aka "text").

I'm not sure what the correct rendering of broken JSON should be - perhaps just an error message, or an error message plus a "raw" representation of the JSON.

As far as I can tell, this isn't a new issue. It has probably always been like this.

Change 852915 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Produce HTML for invalid JSON

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

Change 852915 merged by jenkins-bot:

[mediawiki/core@master] Produce HTML for invalid JSON

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

matmarex subscribed.

Looks like that patch fixed the issue, the last occurrence of the error was on 2022-11-17: https://logstash.wikimedia.org/goto/47e1ae69ea669f5d44b8152173af1a61

image.png (534×2 px, 57 KB)

Change 873760 had a related patch set uploaded (by Bartosz Dziewoński; author: Daniel Kinzler):

[mediawiki/core@REL1_39] Produce HTML for invalid JSON

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

Change 873760 merged by jenkins-bot:

[mediawiki/core@REL1_39] Produce HTML for invalid JSON

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