Page MenuHomePhabricator

Some ApiParse requests fail due to fatal MWException: "not supported for content model"
Open, LowPublic

Description

Error

Request ID: W6M@7grAMG8AAAerQtQAAABL
Request: GET, /w/api.php?...prop=wikitext..&contentformat=text/plain

exception
MWException: Format text/plain is not supported for content model wikitext

#0 /srv/mediawiki/php-1.32.0-wmf.20/includes/content/TextContentHandler.php(46): ContentHandler->checkFormat(string)
#1 /srv/mediawiki/php-1.32.0-wmf.20/includes/content/AbstractContent.php(155): TextContentHandler->serializeContent(WikitextContent, string)
#2 /srv/mediawiki/php-1.32.0-wmf.20/includes/api/ApiParse.php(463): AbstractContent->serialize(string)
#3 /srv/mediawiki/php-1.32.0-wmf.20/includes/api/ApiMain.php(1587): ApiParse->execute()
#4 /srv/mediawiki/php-1.32.0-wmf.20/includes/api/ApiMain.php(531): ApiMain->executeAction()
#5 /srv/mediawiki/php-1.32.0-wmf.20/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#6 /srv/mediawiki/php-1.32.0-wmf.20/api.php(87): ApiMain->execute()
#7 /srv/mediawiki/w/api.php(3): include(string)

Notes

API request fatal rate is increased due to this issue.

It appears that this is a matter of a certain feature not being available yet, or intentionally not provided. That's probably fine, at least in the short-term, but it needs to not crash the request to avoid false alarms. As a stop-gap solution it can probably be caught somewhere along the way and simply reject explicitly so as to mark it a user error (rather than server error).

Related:

Related Objects

StatusAssignedTask
Declineddchen
OpenNone
OpenNone
DuplicateNone
OpenNone
ResolvedAbit
OpenNone
OpenNone
OpenNone
OpenNone
DuplicateNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolvedppelberg
ResolvedKrinkle
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenAnomie
OpenAnomie
OpenNone

Event Timeline

Krinkle created this task.Oct 4 2018, 6:45 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 4 2018, 6:45 PM
Anomie moved this task from Unsorted to Needs Code on the MediaWiki-API board.Oct 5 2018, 2:38 PM
Anomie added a subscriber: Anomie.

What seems to be going on is that it's using a content format intended for interpretation of input text (of which there isn't any in that request) to try and format the output. It looks like ApiEditPage likely has the same issue.

The direct solution would be to remove the passing of a format when calling Content->serialize(). But since both of these modules are going to need some major work soon for MCR anyway, I'm probably not going to bother doing that as a separate patch.

Krinkle added a comment.EditedOct 16 2018, 11:27 PM

Recently triggered via urls such as https://en.wikipedia.org/w/api.php?action=parse&page=Example&contentformat=application/json&prop=wikitext&section=2.

Suppressing in Logstash/new-errors is difficult due the message not having a normal form without variance by user input, and the exception file/line of TextContentHandler.php(46) is too wide.

Using ApiParse.php(463): AbstractContent->serialize(string) for now, seems to be the most specific, whilst still potentially ignoring other errors in the same kind of API call.

Krinkle renamed this task from Some ApiParse reqs fatal due to contentformat to Some ApiParse requests fail due to fatal MWException: "not supported for content model".Nov 4 2018, 8:44 PM
Krinkle added a project: Core Platform Team.

Still seen in the logs for 1.33-wmf.1. Stack trace changed, hence it resurfaced. Exposed from the same urls as T206253#4672796.

MWException: Format text/javascript is not supported for content model wikitext

#0 /srv/mediawiki/php-1.33.0-wmf.1/includes/content/TextContentHandler.php(116): ContentHandler->checkFormat(string)
#1 /srv/mediawiki/php-1.33.0-wmf.1/includes/content/ContentHandler.php(145): TextContentHandler->unserializeContent(string, string)
#2 /srv/mediawiki/php-1.33.0-wmf.1/includes/api/ApiParse.php(222): ContentHandler::makeContent(string, Title, string, string)
#3 /srv/mediawiki/php-1.33.0-wmf.1/includes/api/ApiMain.php(1570): ApiParse->execute()
#4 /srv/mediawiki/php-1.33.0-wmf.1/includes/api/ApiMain.php(531): ApiMain->executeAction()
#5 /srv/mediawiki/php-1.33.0-wmf.1/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#6 /srv/mediawiki/php-1.33.0-wmf.1/api.php(87): ApiMain->execute()
#7 /srv/mediawiki/w/api.php(3): include(string)
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM