Page MenuHomePhabricator

Wikimedia\Assert\ParameterTypeException: Bad value for parameter $target: must be a MediaWiki\Linker\LinkTarget|MediaWiki\Page\PageReference
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\ParameterTypeException: Bad value for parameter $target: must be a MediaWiki\Linker\LinkTarget|MediaWiki\Page\PageReference
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.16/vendor/wikimedia/assert/src/Assert.php(105)
#0 /srv/mediawiki/php-1.37.0-wmf.16/includes/linker/LinkRenderer.php(165): Wikimedia\Assert\Assert::parameterType(array, string, string)
#1 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/classes/LqtView.php(1773): MediaWiki\Linker\LinkRenderer->makeLink(string)
#2 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/classes/LqtView.php(1808): LqtView->showMovedThread(Thread)
#3 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/classes/LqtView.php(2174): LqtView->showSingleThread(Thread)
#4 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/pages/ThreadPermalinkView.php(218): LqtView->showThread(Thread, integer, integer, array)
#5 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/classes/LqtDispatch.php(105): ThreadPermalinkView->show()
#6 /srv/mediawiki/php-1.37.0-wmf.16/extensions/LiquidThreads/classes/LqtDispatch.php(226): LqtDispatch::threadPermalinkMain(OutputPage, Article, Title, User, WebRequest)
#7 /srv/mediawiki/php-1.37.0-wmf.16/includes/HookContainer/HookContainer.php(338): LqtDispatch::tryPage(OutputPage, Article, Title, User, WebRequest, MediaWiki)
#8 /srv/mediawiki/php-1.37.0-wmf.16/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#9 /srv/mediawiki/php-1.37.0-wmf.16/includes/HookContainer/HookRunner.php(2505): MediaWiki\HookContainer\HookContainer->run(string, array)
#10 /srv/mediawiki/php-1.37.0-wmf.16/includes/MediaWiki.php(507): MediaWiki\HookContainer\HookRunner->onMediaWikiPerformAction(OutputPage, Article, Title, User, WebRequest, MediaWiki)
#11 /srv/mediawiki/php-1.37.0-wmf.16/includes/MediaWiki.php(320): MediaWiki->performAction(Article, Title)
#12 /srv/mediawiki/php-1.37.0-wmf.16/includes/MediaWiki.php(925): MediaWiki->performRequest()
#13 /srv/mediawiki/php-1.37.0-wmf.16/includes/MediaWiki.php(559): MediaWiki->main()
#14 /srv/mediawiki/php-1.37.0-wmf.16/index.php(53): MediaWiki->run()
#15 /srv/mediawiki/php-1.37.0-wmf.16/index.php(46): wfIndexMain()
#16 /srv/mediawiki/w/index.php(3): require(string)
#17 {main}
Impact
  • Happened once in the past 4 hours
  • Easy to recreate this issue via GET request
  • Looks like user-input error, but showing up as a fatal
  • Adding Platform Engineering since I think this is mostly not maintained by anyone and I'm hopeful they may have some insight.
Notes

Details

Request URL
https://www.mediawiki.org/w/index.php?title=*&oldid=*

Event Timeline

Pchelolo added a subscriber: Pchelolo.

Solution: underloy LiquidThreads ;)

https://gerrit.wikimedia.org/g/mediawiki/extensions/LiquidThreads/+/9d893a4499d4c269e6b86603dfc531e52b254abd/classes/LqtView.php#1742

		$newTalkpage = is_object( $t_thread ) ? $t_thread->getTitle() : '';
		$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
		$html = wfMessage( 'lqt_move_placeholder' )
			->rawParams( $linkRenderer->makeLink( $target ), $sig )
			->params( $wgLang->date( $thread->modified() ), $wgLang->time( $thread->modified() ) )
			->rawParams( $linkRenderer->makeLink( $newTalkpage ) )->parse();   # <-- fatal here

The fallback for $newTalkpage is the empty string, but LinkRenderer does not like that. The old Linker class ignores invalid ones, but LinkRenderer is used since 2016 - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/LiquidThreads/+/329032

Fix would be a sane fallback or skipping of the talk link, not sure what is better here.

Change 715788 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/LiquidThreads@master] Bypass LinkRenderer failure in LqtView

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

At first, this looked like fall out from change 675189 (T278428), but on closer inspection, that commit only moved and widened the required type. Most likely this will have been fatalling previously as well, with a native "TypeError: expects LinkTarget" error of sorts.

Umherirrender claimed this task.

From my point of view since the inital Linker -> LinkRenderer patch in 2016 - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/LiquidThreads/+/329032

But possible this only happen in some rare error situation, where a thread is missing or such and not for the normal use of threads

Change 715788 merged by jenkins-bot:

[mediawiki/extensions/LiquidThreads@master] LqtView: Fix ParameterTypeException in call to LinkRenderer

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