Page MenuHomePhabricator

Uncaught TypeError: Cannot read property 'lang' of null
Closed, ResolvedPublic

Description

High volume error, mostly impacting Hebrew Wikipedia possibly due to a local gadget there. With 1200 errors in the last 24hr periods this is now one of our top 10 errors (suggested priority: high
https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2020.11.15/clienterror/?id=AXXOQoTZBpCrxDVRLeoa

Screen Shot 2020-11-15 at 9.22.50 PM.png (708×2 px, 144 KB)

My read of the error is that when this occurs the language list will not be compacted.

The code does not appear to be sufficiently defensive and does not consider the situation where unexpected links are adding to the portlet. I would thus recommend applying an array filter to avoid this error.

		return Array.prototype.map.call(
			document.querySelectorAll( '#p-lang [class*="badge"]' ),
			function ( el ) {
				return mw.uls.convertMediaWikiLanguageCodeToULS(
					el.querySelector( '.interlanguage-link-target' ).lang
				);
			}
		);

Stack trace:

at <anonymous>:67:752
at Array.CompactInterlanguageList.getLangsWithBadges  <anonymous>:67:593
at CompactInterlanguageList.compact  <anonymous>:66:950
at CompactInterlanguageList.getCompactList  <anonymous>:66:330
at CompactInterlanguageList.init  <anonymous>:63:834
at HTMLDocument.createCompactList  <anonymous>:69:197
at mightThrow  URL1:49:149
at process  URL1:49:808

URL1: https://he.wikipedia.org/w/load.php?lang=he&modules=jquery%7Cjquery.ui&skin=vector&version=1pc1u

Event Timeline

Jdlrobson updated the task description. (Show Details)

I'm not very experienced with Kibana... If a local gadget is suspect, can we know anything about it? I cannot find anything obvious.

I think just using document.querySelectorAll( '#p-lang [class*="badge"] .interlanguage-link-target' ), would be enough.

My guess is there might be a gadget on Hebrew Wikipedia adding an element e.g. a button into the language list which doesn't match the selector which causes the code to trip up.

If so it won't show up in the stack trace, but with knowledge of Hebrew Wikipedia's popular gadgets you might be able to track it down.

Change 641384 had a related patch set uploaded (by Amire80; owner: Amire80):
[mediawiki/extensions/UniversalLanguageSelector@master] Make a more specific CSS selector in getLangsWithBadges

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

Change 641384 merged by jenkins-bot:
[mediawiki/extensions/UniversalLanguageSelector@master] Make a more specific CSS selector in getLangsWithBadges

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

The change is merged. I guess that someone should check that these errors go away after it's deployed. How urgent is it to deploy it? Does it justify a backport or can it wait for the train?

I think this can ride the train. I'm currently classifying more than 1000 errors a day as UBN, and this is just below the threshold. I'll confirm the fix when this rolls out.

Am seeing this error disappear on Hebrew Wikipedia with the wmf20 roll out today. thanks!

Screen Shot 2020-12-02 at 2.26.53 PM.png (1×2 px, 348 KB)

https://logstash.wikimedia.org/goto/3b301f0903afb3b61f6593a767405ec7