Page MenuHomePhabricator

languageinfo API returns a TypeError if you request fallbacks
Closed, ResolvedPublic

Description

I use the following API request in the code of DiscordWikiBot:

https://ru.wikipedia.org/w/api.php?action=query&meta=languageinfo&liprop=code|autonym|name|fallbacks|variants

Some time ago, it started to return the following response if you request fallbacks parameter:

{
    "error": {
        "code": "internal_api_error_TypeError",
        "info": "[Xhg2swpAMEUAAFPHYF0AAAAY] Caught exception of type TypeError",
        "errorclass": "TypeError"
    },
    "servedby": "mw1234"
}

Removing some parameters from URL doesn’t change anything as long as fallbacks is present. I need fallbacks more than anything in my code, and would like to see this fixed.

This API was introduced in T220415.

Details

Request ID
Xhg2swpAMEUAAFPHYF0AAAAY
Request URL
https://ru.wikipedia.org/w/api.php?action=query&meta=languageinfo&liprop=code|autonym|name|fallbacks|variants
Stack Trace
2020-01-10 08:32:52 [Xhg2swpAMEUAAFPHYF0AAAAY] mw1234 ruwiki 1.35.0-wmf.14 exception
ERROR: [Xhg2swpAMEUAAFPHYF0AAAAY] /w/api.php?action=query&meta=languageinfo&liprop=code|autonym|name|fallbacks|variants
TypeError from line 616 of /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiResult.php:
Argument 1 passed to ApiResult::setIndexedTagName() must be of the type array, null given,
called in /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiQueryLanguageinfo.php on line 182 {"exception_id":"Xhg2swpAMEUAAFPHYF0AAAAY","exception_url":"/w/api.php?action=query&meta=languageinfo&liprop=code|autonym|name|fallbacks|variants","caught_by":"mwe_handler"} 
[Error TypeError] (/srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiResult.php:616) Argument 1 passed to ApiResult::setIndexedTagName() must be of the type array, null given, called in /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiQueryLanguageinfo.php on line 182
#0 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiQueryLanguageinfo.php(182): ApiResult::setIndexedTagName(NULL, string)
#1 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiQuery.php(255): ApiQueryLanguageinfo->execute()
#2 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(1603): ApiQuery->execute()
#3 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(539): ApiMain->executeAction()
#4 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(510): ApiMain->executeActionWithErrorHandling()
#5 /srv/mediawiki/php-1.35.0-wmf.14/api.php(78): ApiMain->execute()
#6 /srv/mediawiki/w/api.php(3): require(string)
#7 {main}
Related Gerrit Patches:

Event Timeline

stjn created this task.Jan 10 2020, 8:38 AM
Restricted Application added a project: Core Platform Team. · View Herald TranscriptJan 10 2020, 8:38 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DannyS712 changed the subtype of this task from "Task" to "Production Error".Jan 10 2020, 8:48 AM
DannyS712 set Request URL to https://ru.wikipedia.org/w/api.php?action=query&meta=languageinfo&liprop=code|autonym|name|fallbacks|variants.
DannyS712 set Request ID to Xhg2swpAMEUAAFPHYF0AAAAY.
DannyS712 edited Stack Trace. (Show Details)

Change 563394 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] ApiQueryLanguageinfo: Use empty array if there are no fallbacks

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

Change 563422 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/core@master] Fix fallbacks of mrj (Hill Mari)

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

Anomie added a subscriber: Anomie.EditedJan 10 2020, 2:50 PM

This appears to have been caused by rMW639d4a96741a: Define mhr and mrj as fallback for each other, which set a configuration value to an array rather than a comma-separated string. That in turn causes some internal methods to return null despite being declared to return only array.

Change 563394 abandoned by DannyS712:
ApiQueryLanguageinfo: Use empty array if there are no fallbacks

Reason:
Not the reason

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

Eevans triaged this task as Medium priority.Jan 10 2020, 5:05 PM
Hmxhmx added a subscriber: Hmxhmx.Jan 10 2020, 6:51 PM

Change 563422 merged by jenkins-bot:
[mediawiki/core@master] Fix fallbacks of mrj (Hill Mari)

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

Anomie closed this task as Resolved.Jan 13 2020, 6:19 PM
Anomie assigned this task to Lucas_Werkmeister_WMDE.

Fix should be deployed to Wikimedia sites with 1.35.0-wmf.15.

Change 565072 had a related patch set uploaded (by Jforrester; owner: Lucas Werkmeister (WMDE)):
[mediawiki/core@wmf/1.35.0-wmf.14] Fix fallbacks of mrj (Hill Mari)

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

Change 565072 merged by jenkins-bot:
[mediawiki/core@wmf/1.35.0-wmf.14] Fix fallbacks of mrj (Hill Mari)

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

Mentioned in SAL (#wikimedia-operations) [2020-01-15T21:03:37Z] <jforrester@deploy1001> Synchronized php-1.35.0-wmf.14/languages/messages/MessagesMrj.php: Fix fallbacks of mrj (Hill Mari) T242409 T242796 (duration: 01m 05s)