Page MenuHomePhabricator

TypeError: Argument 1 passed to MediaWiki\Utils\UrlUtils::parse() must be of the type string, null given (Translate extension)
Closed, ResolvedPublic4 Estimated Story PointsPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   TypeError: Argument 1 passed to MediaWiki\Utils\UrlUtils::parse() must be of the type string, null given, called in /srv/mediawiki/php-1.44.0-wmf.4/extensions/Translate/src/TtmServer/SearchTranslationsSpecialPage.php on line 23
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.4/includes/utils/UrlUtils.php(421)
#0/srv/mediawiki/php-1.44.0-wmf.4/extensions/Translate/src/TtmServer/SearchTranslationsSpecialPage.php(230)MediaWiki\Utils\UrlUtils->parse(null)
#1/srv/mediawiki/php-1.44.0-wmf.4/includes/specialpage/SpecialPage.php(729)MediaWiki\Extension\Translate\TtmServer\SearchTranslationsSpecialPage->execute(null)
#2/srv/mediawiki/php-1.44.0-wmf.4/includes/specialpage/SpecialPageFactory.php(1726)MediaWiki\SpecialPage\SpecialPage->run(null)
#3/srv/mediawiki/php-1.44.0-wmf.4/includes/actions/ActionEntryPoint.php(504)MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#4/srv/mediawiki/php-1.44.0-wmf.4/includes/actions/ActionEntryPoint.php(146)MediaWiki\Actions\ActionEntryPoint->performRequest()
#5/srv/mediawiki/php-1.44.0-wmf.4/includes/MediaWikiEntryPoint.php(200)MediaWiki\Actions\ActionEntryPoint->execute()
#6/srv/mediawiki/php-1.44.0-wmf.4/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#7/srv/mediawiki/w/index.php(3)require(string)
#8{main}
Impact

One specific search query (so far) gives a fatal errors to the user.

Notes

There's PHP Notice: Undefined index: uri preceding each error.

All documents in the index should have an uri. Sounds like something may be corrupted in the translation memory index.

Details

Request URL
https://meta.wikimedia.org/w/index.php?filter=*&language=*&query=*&title=*

Event Timeline

Nikerabbit updated the task description. (Show Details)
Nikerabbit set the point value for this task to 4.

My initial assumption about faulty documents is wrong (thanks @ EBernhardson)

The query has filter=translated parameter, which causes CrossLanguageTranslationSearchQuery to be invoked. This returns dynamically constructed documents that don't have all fields. Generally this is not a problem, because these messages are treated as local in this code path:

SearchTranslationsSpecialPage.php
			$handle = new MessageHandle( $title );

			if ( $handle->isValid() ) {
				$uri = Utilities::getEditorUrl( $handle, 'search' );
				$link = Html::element(
					'a',
					[ 'href' => $uri ],
					$this->msg( 'tux-sst-edit' )->text()
				);
			} else {
				$url = $this->urlUtils->parse( $document['uri'] );
				if ( !$url ) {
					continue;
				}
				$domain = $url['host'];
				$link = Html::element(
					'a',
					[ 'href' => $document['uri'] ],
					$this->msg( 'tux-sst-view-foreign', $domain )->text()
				);
			}

In the case of error, $handle->isValid() returns false.

Best course of action seems to make the code more robust and add more logging.

Change #1098502 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/extensions/Translate@master] SearchTranslationsSpecialPage: Add more logging for T380961

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

Change #1098502 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] SearchTranslationsSpecialPage: Add more logging for T380961

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

After deployment we should get more info to investigate further.

The translation unit in question is Translations:Movement Charter/Drafting Committee/Newsletter/1/1/ja and it belonged to translatable page https://meta.wikimedia.org/w/index.php?title=Movement_Charter%2FDrafting_Committee%2FNewsletter%2F1&veaction=editsource some time in the past but no longer.

It is correctly degraded to INFO level right now. It's probably one-off case given this error isn't more frequent.

There is one bug in the code, which I'll fix and then we can close this.

Change #1100801 had a related patch set uploaded (by Nikerabbit; author: Nikerabbit):

[mediawiki/extensions/Translate@master] SearchTranslationsSpecialPage: Correct logger placeholder syntax

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

Change #1100801 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] SearchTranslationsSpecialPage: Correct logger placeholder syntax

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

Error has been fixed by silently ignoring problematic results. Logging typofix can get deployed on its own.