Page MenuHomePhabricator

BadMethodCallException for API call on ru.wikipedia: "Call to a member function getPrefixedText() on a non-object (null)"
Closed, ResolvedPublicPRODUCTION ERROR

Description

https://ru.wikipedia.org API behaves much differently from the others.

https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageprops&generator=mostviewed&ppprop=wikibase_item&gpvimlimit=50&gpvimoffset=950 : 50 items are not present here yet it does not throw a server error.
Output:

{"batchcomplete":"","query":{"pages":{"-1":{"ns":-1,"title":"Special:GlobalUsage","special":""},"48370461":{"pageid":48370461,"ns":0,"title":"Al Jazeera","pageprops":{"wikibase_item":"Q13477"}},"60455502":{"pageid":60455502,"ns":0,"title":"Angel's Last Mission: Love","pageprops":{"wikibase_item":"Q63067137"}},"595394":{"pageid":595394,"ns":0,"title":"Anthony Bourdain","pageprops":{"wikibase_item":"Q426582"}},"52139":{"pageid":52139,"ns":0,"title":"Audrey Hepburn","pageprops":{"wikibase_item":"Q42786"}},
.......
,"255195":{"pageid":255195,"ns":0,"title":"Zodiac Killer","pageprops":{"wikibase_item":"Q218148"}}}}}

https://ru.wikipedia.org/w/api.php?action=query&format=json&prop=pageprops&generator=mostviewed&ppprop=wikibase_item&gpvimlimit=50&gpvimoffset=250 : Here also 50 items are not present but it throws a server error. (with gpvimlimit=11 it works fine.)

{"error":{"code":"internal_api_error_BadMethodCallException","info":"[XQRpmwpAEDUAAFnJ5qwAAAAV] Caught exception of type BadMethodCallException","errorclass":"BadMethodCallException"},"servedby":"mw1288"}

Also in other en and other API's no error is thrown even if the limit exceeds 500 (it just returns 500 items or the limit whatever is lower).

Background: T215222: Recommendation API translation endpoint stopped working

[XQRm9gpAEDcAAJMJPRoAAAAK]
/srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiPageSet.php:1186
exception.message
Call to a member function getPrefixedText() on a non-object (null)
exception.trace
#0 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiPageSet.php(798): ApiPageSet->processTitlesArray(array)
#1 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiPageSet.php(720): ApiPageSet->initFromTitles(array)
#2 /srv/mediawiki/php-1.34.0-wmf.8/extensions/PageViewInfo/includes/ApiQueryMostViewed.php(52): ApiPageSet->populateFromTitles(array)
#3 /srv/mediawiki/php-1.34.0-wmf.8/extensions/PageViewInfo/includes/ApiQueryMostViewed.php(24): MediaWiki\Extensions\PageViewInfo\ApiQueryMostViewed->run(ApiPageSet)
#4 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiPageSet.php(176): MediaWiki\Extensions\PageViewInfo\ApiQueryMostViewed->executeGenerator(ApiPageSet)
#5 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiPageSet.php(140): ApiPageSet->executeInternal(boolean)
#6 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiQuery.php(234): ApiPageSet->execute()
#7 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(1595): ApiQuery->execute()
#8 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(531): ApiMain->executeAction()
#9 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#10 /srv/mediawiki/php-1.34.0-wmf.8/api.php(87): ApiMain->execute()
#11 /srv/mediawiki/w/api.php(3): include(string)
#12 {main}

Event Timeline

Usmanmuhd renamed this task from Error with RuWikiAPi to Error with RuWikiAPI.Jun 15 2019, 2:27 AM
Aklapper renamed this task from Error with RuWikiAPI to BadMethodCallException for API call on ru.wikipedia: "Call to a member function getPrefixedText() on a non-object (null)".Jun 15 2019, 3:35 AM
Aklapper updated the task description. (Show Details)
Aklapper updated the task description. (Show Details)
Umherirrender subscribed.

T208691 was a similar issue with invalid titles in the mostviewed data, but the different maybe that this bug is using the module as generator

Anomie subscribed.

This seems to be similar to T208691, this time affecting the code path where ApiQueryMostViewed is being used as a generator. The fix would be similar, the return value from Title::newFromText() at line 50 needs to be checked for null before being added to the array.

It's possible that the reproduction case may have gone away if the page views data has changed so there's no longer an invalid title in the ruwiki results. The bug does still seem to exist in the code.

Change 525432 had a related patch set uploaded (by Ppchelko; owner: Ppchelko):
[mediawiki/extensions/PageViewInfo@master] ApiQueryMostViewed: skip invalid titles when used as generator.

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

Change 525432 merged by jenkins-bot:
[mediawiki/extensions/PageViewInfo@master] ApiQueryMostViewed: skip invalid titles when used as generator.

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

Pchelolo claimed this task.
Pchelolo subscribed.

Checked again, now it works as expected. Resolving.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:06 PM