Page MenuHomePhabricator

MediaWiki:Editcheck-config.json: Invariant failed: Page should be known
Closed, ResolvedPublicBUG REPORT

Description

1738 such errors in the last few days, concentrated in a few spikes. They are all for /w/rest.php/v1/page/MediaWiki:Editcheck-config.json.

Error
labels.normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\InvariantException: Invariant failed: Page should be known
error.stack_trace
from /srv/mediawiki/php-1.42.0-wmf.1/vendor/wikimedia/assert/src/Assert.php(231)
#0 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/Handler/PageSourceHandler.php(70): Wikimedia\Assert\Assert::invariant(boolean, string)
#1 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/SimpleHandler.php(38): MediaWiki\Rest\Handler\PageSourceHandler->run(string)
#2 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/Router.php(517): MediaWiki\Rest\SimpleHandler->execute()
#3 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/Router.php(422): MediaWiki\Rest\Router->executeHandler(MediaWiki\Rest\Handler\PageSourceHandler)
#4 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/EntryPoint.php(195): MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#5 /srv/mediawiki/php-1.42.0-wmf.1/includes/Rest/EntryPoint.php(135): MediaWiki\Rest\EntryPoint->execute()
#6 /srv/mediawiki/php-1.42.0-wmf.1/rest.php(31): MediaWiki\Rest\EntryPoint::main()
#7 /srv/mediawiki/w/rest.php(3): require(string)
#8 {main}

Details

Event Timeline

Tagging Editing FYI, but this sounds like a PageSourceHandler bug.

DLynch subscribed.

This is (almost certainly) entirely me causing the error spikes by doing something with the API to compare message-overrides across wikis (i.e. sending a REST API request to every single wikipedia for certain messages). That's the error that happens when a message isn't overridden on a given wiki -- e.g. https://nah.wikipedia.org/w/rest.php/v1/page/MediaWiki:Editcheck-config.json

I didn't look around for other pages that might cause it, but this being specific to the slightly strange nature of translation messages in the MediaWiki namespace seems plausible -- they exist as pages if they're in the language JSON files, but might not actually have any revisions backing them if they've not been overridden.

Right but that's the point of "known page" system - to indicate pages which have content but not revisions. The API handler uses different conditions for different pathways (PageContentHelper::hasContent() allows for system messages but PageSourceHandler insists on having a Page object) and gets confused. (It also doesn't handle global user pages, global file pages etc, although it doesn't throw an error for those but not returning the page content still seems like incorrect behavior.)

For non-overridden interface messages, we could redirect to "revision 0" and then serve the translation file content for that revision 0. Any future override would return content from a non-zero "real" revision (see T349868: page/<title>/html and with_html endpoints fails with InvalidArgumentException for overridden interface messages with JSON content).

daniel triaged this task as High priority.

I think the fix for now is to return a 404 instead of failing hard.
Note that with this fix, page/MediaWiki:Editcheck-config.json will return a 404, but page/MediaWiki:Editcheck-config.json/html will return the rendered message (modulo a fix for T349868). That seems ok to me, but it means that page/MediaWiki:Editcheck-config.json/with_html will also return a 404. That's a bit awkward.

If we want to return something other than a 404 from the page-metadata endpoint for non-overwritten message pages, I suggest to file a new ticket for that.

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

[mediawiki/core@master] REST: PageSourceHandler: Don't crash on message pages.

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

Change 973146 merged by jenkins-bot:

[mediawiki/core@master] REST: PageSourceHandler: Don't crash on message pages.

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

Logstash doesn't show this exception in the last 7 days. Resolving.