Page MenuHomePhabricator

Several articles inaccessible due to fatal ParameterAssertionException "Bad value for parameter $dbkey: should not be empty"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

Request URL: GET slwiki /wiki/Medijska_psihologija (and other page view urls on other wikis)
Request ID: XPMQ7QpAMFQAAI8I-p0AAAAN

message
ParameterAssertionException:  Bad value for parameter $dbkey: should not be empty unless namespace is main and fragment is non-
trace
#1 /srv/mediawiki/php-1.34.0-wmf.7/includes/title/NamespaceInfo.php(162): TitleValue->__construct(integer, string)
#2 /srv/mediawiki/php-1.34.0-wmf.7/includes/Title.php(1523): NamespaceInfo->getTalkPage(Title)
#3 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/CoreParserFunctions.php(715): Title->getTalkPage()
#4 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3602): CoreParserFunctions::talkpagename(Parser, string)
#5 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3309): Parser->callParserFunction(PPTemplateFrame_Hash, string, array)
#6 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#7 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3226): PPFrame_Hash->expand(PPNode_Hash_Tree)
#8 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#9 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3226): PPFrame_Hash->expand(PPNode_Hash_Tree)
#10 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#11 /srv/mediawiki/php-1.34.0-wmf.7/extensions/ParserFunctions/includes/ParserFunctions.php(116): PPFrame_Hash->expand(PPNode_Hash_Tree)
#12 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3602): MediaWiki\Extensions\ParserFunctions\ParserFunctions::ifObj(Parser, PPTemplateFrame_Hash, array)
#13 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3309): Parser->callParserFunction(PPTemplateFrame_Hash, string, array)
#14 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#15 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3483): PPFrame_Hash->expand(PPNode_Hash_Tree)
#16 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#17 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3483): PPFrame_Hash->expand(PPNode_Hash_Tree)
#18 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPTemplateFrame_Hash)
#19 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3483): PPFrame_Hash->expand(PPNode_Hash_Tree)
#20 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPFrame_Hash)
#21 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(3123): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#22 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(1432): Parser->replaceVariables(string)
#23 /srv/mediawiki/php-1.34.0-wmf.7/includes/parser/Parser.php(564): Parser->internalParse(string)
#24 /srv/mediawiki/php-1.34.0-wmf.7/includes/content/WikitextContent.php(365): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#25 /srv/mediawiki/php-1.34.0-wmf.7/includes/content/AbstractContent.php(555): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
#26 /srv/mediawiki/php-1.34.0-wmf.7/includes/Revision/RenderedRevision.php(265): AbstractContent->getParserOutput(Title, integer, ParserOptions, boolean)
#27 /srv/mediawiki/php-1.34.0-wmf.7/includes/Revision/RenderedRevision.php(234): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean)
#28 /srv/mediawiki/php-1.34.0-wmf.7/includes/Revision/RevisionRenderer.php(193): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string)
#29 /srv/mediawiki/php-1.34.0-wmf.7/includes/Revision/RevisionRenderer.php(142): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)
#30 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#31 /srv/mediawiki/php-1.34.0-wmf.7/includes/Revision/RenderedRevision.php(197): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)
#32 /srv/mediawiki/php-1.34.0-wmf.7/includes/poolcounter/PoolWorkArticleView.php(196): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#33 /srv/mediawiki/php-1.34.0-wmf.7/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork()
#34 /srv/mediawiki/php-1.34.0-wmf.7/includes/page/Article.php(773): PoolCounterWork->execute()
#35 /srv/mediawiki/php-1.34.0-wmf.7/includes/actions/ViewAction.php(68): Article->view()
#36 /srv/mediawiki/php-1.34.0-wmf.7/includes/MediaWiki.php(499): ViewAction->show()
#37 /srv/mediawiki/php-1.34.0-wmf.7/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#38 /srv/mediawiki/php-1.34.0-wmf.7/includes/MediaWiki.php(865): MediaWiki->performRequest()
#39 /srv/mediawiki/php-1.34.0-wmf.7/includes/MediaWiki.php(515): MediaWiki->main()
#40 /srv/mediawiki/php-1.34.0-wmf.7/index.php(42): MediaWiki->run()

Impact

Based on the stack trace, it seems the trigger for this problem is use of the {{TALKPAGENAME}} parser function in some template used by the article.

  • Several wiki pages are inaccessible. Users are shown a generic internal error page.
  • These page views are not cacheable by Varnish.
  • Viewing them causes a fatal error with HTTP 5xx status code.

Notes

Given the stack trace involves Title->getTalkPage this is likely caused by the same change that also caused T224811.

Examples include:

Event Timeline

Krinkle created this task.Jun 2 2019, 12:03 AM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptJun 2 2019, 12:03 AM
Krinkle triaged this task as High priority.Jun 2 2019, 12:04 AM

Logstash query:
+exception.trace:"CoreParserFunctions.php" +exception.message:"Bad value for parameter"

daniel added a comment.Jun 3 2019, 8:43 PM

The obvious fix is to catch the exception, but the question is - where is the correct place to catch it? NamespaceInfo->getTalkPage(Title) and Title->getTalkPage(Title) can't catch it, since they must return a (valid) LinkTarget resp Title - and how would they construct that? And CoreParserFunctions::talkpagename() could catch it, but why would it hide a problem that arises from it being passed a bad Title in the first place?---

The thing is - Title->getTalkPage() can only fail this way if the original Title object was invalid (empty) already.

Perhaps we should log the creation of empty Title objects, so we know when and why that happens.

daniel added a comment.Jun 3 2019, 9:31 PM

Actually, looking at this some more, I wonder why Title::newFromText() returns an invalid title in CoreParserFunctions::talkpagename(). It should return null if $title is empty.

daniel added a comment.Jun 3 2019, 9:47 PM

Found it:

MediaWikiCodec::parseTitle( '#foo' ) will return a valid LinkTarget (and consequently Title::newFromText( '#foo' ) will return a valid Title), pointing to an anchor on the current page. But such a LinkTarget doesn't represent a page, so it doesn't have a talk page. 'Talk:#foo' is not a valid title!

So the assumption that any valid Title has a corresponding valid talk page (and subject page) Title fails. Unfortunately, this assumption is baked into NamespaceInfo since https://gerrit.wikimedia.org/r/507081 / e30cb5ba90860. I'll see how this can best be resolved.

So it all boiled down to making getTalk() consistently fail on relative links (and interwiki links), and making canHaveTalkPage() reflect that. CoreParserFunctions is already checking canHaveTalkPage(), but getting true for '#' or ':#', which is wrong.

I cooked up a patch, let's see what other fun things it breaks :)

Change 514192 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Ensure canHaveTalkPage returns false when getTalkPage would fail.

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

Change 514192 merged by jenkins-bot:
[mediawiki/core@master] Ensure canHaveTalkPage returns false when getTalkPage would fail.

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

daniel closed this task as Resolved.Jul 17 2019, 4:11 PM
daniel claimed this task.
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:06 PM