Page MenuHomePhabricator

TypeError: Cannot read properties of null (reading 'toLowerCase') at at mw.language.getData
Closed, ResolvedPublicPRODUCTION ERROR

Description

Occurring inside https://codesearch.wmcloud.org/search/?q=getSeparatorTransformTable&i=nope&files=&excludeFiles=&repos=
In last 7 days error occurred 1,018 times.

Error
normalized_message
TypeError: Cannot read properties of null (reading 'toLowerCase')
at Object.getData  <anonymous>:380:1241
at Object.getSeparatorTransformTable  <anonymous>:387:462
at Object.convertNumber  <anonymous>:386:438
at Object.getLastModifiedMessage  <anonymous>:287:722
at initHistoryLink  <anonymous>:182:714
at HTMLSpanElement.<anonymous>  <anonymous>:183:475
at Function.each  https://es.m.wikipedia.org/w/load.php?lang=es&modules=ext.discussionTools.init%7Cjquery%2Cmoment%2Coojs-ui-core&skin=minerva&version=56atz:307:285
at jQuery.fn.init.each  https://es.m.wikipedia.org/w/load.php?lang=es&modules=ext.discussionTools.init%7Cjquery%2Cmoment%2Coojs-ui-core&skin=minerva&version=56atz:305:93
at initModifiedInfo  <anonymous>:183:459
at HTMLDocument.<anonymous>  <anonymous>:184:675
Impact

Last modified message on mobile rendering incorrectly.

Notes

Event Timeline

This is an issue with mediawiki.language but I'm not sure what the appropriate tag is.
The Mobilefrontend call triggering this looks pretty harmless - it's either 0 or 1:
https://gerrit.wikimedia.org/g/mediawiki/extensions/MobileFrontend/+/8c3a95825084f26e8bacaf36a4022357d03303b2/src/mobile.startup/time.js#110

Nikerabbit subscribed.

It seems mw.config.get( 'wgUserLanguage' ) returns null for some reason in these cases. It gets passed to getData which then fails in langCode = langCode.toLowerCase();.

Since this doesn't seem to be related to languages per se, I am untagging Language-Team per our maintenance levels.

Jdlrobson unsubscribed.

wgUserLanguage is added via includes/ResourceLoader/ResourceLoader.php.

Looking closely most of the errors came from a single client (anonymous) but there are 4 different users impacted by the error, so perhaps this should be declined, but might also point to some kind of cache poisoning (I've not thought too much about that)?.

Krinkle triaged this task as High priority.
Krinkle moved this task from Inbox, needs triage to Doing: Goals on the Performance-Team board.

This is most likely due to an extension adding a key-value pair to mw.config with a string that is not valid UTF-8. This means it can't be encoded as JSON, and thus fails the blob.

This task currently lacks any detail to know what URL it is failing on what extensions may be active for a given combination of (wiki, user account, page title) and by extent skin/language preferences.

This seems to come up once or twice a year, with usually a dedicated task for specific breakages once identified, such as:

As part of T206475, we decided to make this category of issue more visible by adding a fatal error instead of continuing to render the page without mw.config. As per T328037, this logic is still working and incurring a fatal error. However, the issue in this task did not receive a fatal error because the invalid data encountered here is part of the RLCONF payload in the <head> which we format with Context->encodeJson() rather than the old static ResourceLoader::makeConfigSetScript. The former was introduced for T32956, and adopted in https://gerrit.wikimedia.org/r/503705 (cd45307ba16230) to improve performance.

Given that this task has not yet identified which extension broke it, I'll focus this task on fixing the detection in RL and thus the side-effect observed by mw.language.getData. There will then later be a separate task for the root cause, which as per the above, is likely an extension adding invalid data.

Change 889256 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] ResourceLoader: Permit partial failure of encodeJson() and add logging

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

Change 889258 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] ResourceLoader: Permit partial failure in OutputPage::getBottomScripts

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

Change 889256 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Permit partial failure of encodeJson() and add logging

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

Change 889258 merged by jenkins-bot:

[mediawiki/core@master] ResourceLoader: Permit partial failure in OutputPage::getBottomScripts

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