Page MenuHomePhabricator

Translate QueryMessageCollectionActionApi: PHP Notice: Uninitialized string offset: 0
Closed, ResolvedPublic1 Estimated Story PointsPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   PHP Notice: Uninitialized string offset: 0
error.stack_trace
from /srv/mediawiki/php-1.41.0-wmf.6/extensions/Translate/src/MessageLoading/QueryMessageCollectionActionApi.php(138)
#0 /srv/mediawiki/php-1.41.0-wmf.6/extensions/Translate/src/MessageLoading/QueryMessageCollectionActionApi.php(138): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.41.0-wmf.6/extensions/Translate/src/MessageLoading/QueryMessageCollectionActionApi.php(48): MediaWiki\Extension\Translate\MessageLoading\QueryMessageCollectionActionApi->run()
#2 /srv/mediawiki/php-1.41.0-wmf.6/includes/api/ApiQuery.php(679): MediaWiki\Extension\Translate\MessageLoading\QueryMessageCollectionActionApi->execute()
#3 /srv/mediawiki/php-1.41.0-wmf.6/includes/api/ApiMain.php(1908): ApiQuery->execute()
#4 /srv/mediawiki/php-1.41.0-wmf.6/includes/api/ApiMain.php(884): ApiMain->executeAction()
#5 /srv/mediawiki/php-1.41.0-wmf.6/includes/api/ApiMain.php(855): ApiMain->executeActionWithErrorHandling()
#6 /srv/mediawiki/php-1.41.0-wmf.6/api.php(91): ApiMain->execute()
#7 /srv/mediawiki/php-1.41.0-wmf.6/api.php(46): wfApiMain()
#8 /srv/mediawiki/w/api.php(3): require(string)
#9 {main}
Impact
  • Small number of these over the past week: 2× per day
  • All seem to be from wikidatawiki
  • Easy to recreate via GET request

Details

Request URL
https://www.wikidata.org/w/api.php?action=query&errorformat=*&format=*&formatversion=*&list=*&mcfilter=*&mcgroup=*&mclanguage=*&mclimit=*&mcprop=*&rawcontinue=*

Event Timeline

Wangombe changed the task status from Open to In Progress.May 22 2023, 11:12 AM
Wangombe claimed this task.

The | character is used in URL parameters as a delimiter for different items within the same parameter. From the logstash link, the mcfilter parameter would be interpreted as an array with three items:

  • An empty string before the first |
  • nslookup domain.example.com'
  • perl -e \"gethostbyname('domain.example.com')\"

The first empty string item is causing the Uninitialized string offset: 0 error when code tries to access the first character of each item in the filter array in QueryMessageCollectionActionApi.php#138.

When building the query, it is possible that a filter may have been added then removed, but the pipe, |, still stuck around before the request was made. I think removing empty strings in the filter array should prevent this error from occurring.

Change 922794 had a related patch set uploaded (by Wangombe; author: Wangombe):

[mediawiki/extensions/Translate@master] QueryMessageCollectionActionApi: Check for empty filter

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

Wangombe set the point value for this task to 2.May 25 2023, 8:34 AM
Wangombe changed the point value for this task from 2 to 1.May 25 2023, 8:36 AM

Change 922794 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] QueryMessageCollectionActionApi: Check for empty filter

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

Nikerabbit subscribed.

Confirmed with Logstash by requesting a filter with empty value in wikidata.org.