Page MenuHomePhabricator

Error: Collection contains more than one element
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: n/a

message
Error: Collection contains more than one element

at OO.ui.Element.static.unsafeInfuse URL1:289:902
at OO.ui.Element.static.infuse URL1:289:545
at OO.ui.infuse URL1:286:29
at infuseSelectAllToHeader URL1:1:263
at URL1:2:260
at fire URL1:159:198
at fireWith URL1:160:391
at fire URL1:634:436
at URL1:651:1585
at mightThrow URL1:162:141
at resolve/</process< URL1:162:800

URL1: https://de.wikipedia.org/w/load.php?lang=de&modules=ext.GlobalPreferences.global%7Cext.centralNotice.geoIP%7Cext.centralauth.ForeignApi%7Cext.centralauth.centralautologin.clearcookie%7Cext.cx.eventlogging.campaigns%7Cext.echo.api%2Cinit%7Cext.eventLogging%2CnavigationTiming%2Cpopups%2CwikimediaEvents%7Cext.uls.common%2Ccompactlinks%2Cinterface%2Cpreferences%2Cwebfonts%7Cjquery%2Coojs%2Coojs-ui-core%2Coojs-ui-widgets%7Cjquery.client%2Ccookie%2ClengthLimit%2CtextSelection%7Cjquery.uls.data%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Cbase%2Ccldr%2CconfirmCloseWindow%2Ccookie%2Cexperiments%2Chtmlform%2CjqueryMsg%2Clanguage%2Cnotification%2Cstorage%2Cuser%2Cutil%2CvisibleTimeout%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.editfont.styles%7Cmediawiki.htmlform.ooui%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.notification.convertmessagebox%7Cmediawiki.page.ready%7Cmediawiki.special.preferences.ooui%7Cmediawiki.ui.button%7Cmediawiki.widgets.CheckMatrixWidget%2CSelectWithInputWidget%2CTitlesMultiselectWidget%2CUsersMultiselectWidget%2CvisibleLengthLimit%7Coojs-ui-widgets.icons%7Coojs-ui.styles.icons-content%7Cskins.vector.legacy.js%7Cuser.defaults&skin=vector&version=q1nq5

Impact

Notes

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Krinkle updated the task description. (Show Details)

I'm guessing the theory is that ext.GlobalPreferences.global, whilst merely one of hundreds of modules loaded in that batch, stands out because from a Codesearch we see that it is only rarely loaded on pages (specifically, Special:GlobalPreferences). And that on that page, this module is the primary JS code that runs and thus the most likely cause of errors if an error happens on that page.

Without a Logstash URL this is hard to confirm or investigate, but since I spent a few minutes doing the same as you already did, I figured I'd at least record it this time, for CommTech's benefit :)

https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-2021.04.14?id=jurC0XgBg_6mGHGhgHIz (it's also got a filter on the board per our new convention)

All error URLs point to the special page.

I'm not sure how to follow up on this, can we get more data on this error?

The only data I have is the errors coming in on logstash.

The error message comes from OOjs UI when unsafeInfuse is called https://gerrit.wikimedia.org/g/mediawiki/core/+/9c74a067c39fa801362b1291baa946ee89e5e51c/resources/lib/ooui/oojs-ui-core.js#721 (which is called when infuse is called on an empty collection)

According to stack trace infuseSelectAllToHeader is to blame which points to https://gerrit.wikimedia.org/g/mediawiki/extensions/GlobalPreferences/+/421d17f9a40b517fe2401643581a5c8740d2aa01/resources/ext.GlobalPreferences.global.js#17

which means $root.find( '.globalprefs-section-select-all' ) is not matching any elements.

Somebody with knowledge of GlobalPreferences should debug why this is happening to understand and fix this bug (I know nothing about this extension).

The error message comes from OOjs UI when unsafeInfuse is called https://gerrit.wikimedia.org/g/mediawiki/core/+/9c74a067c39fa801362b1291baa946ee89e5e51c/resources/lib/ooui/oojs-ui-core.js#721 (which is called when infuse is called on an empty collection)

That code says if ( $elem.length > 1 ), i.e. if there's more than one element, not when it's empty.

The .globalprefs-section-select-all element is being added server-side, so it seems unlikely that it wouldn't ever be found (i.e. as it could perhaps be if it was being added client-side and things were happening in a different order sometimes).

The error seems to be happening on many different wikis, so is probably not an incompatibility with a user script or gadget. However, it does look like it's only Wikipedias, Meta, and Commons.

The htmlform.enhance JS hook is fired in tab.js when a preference section is made visible for the first time, and at that point it's passed the panel root element (which is what we want). But it's also fired in htmlform.js and elsewhere and given the whole document or other elements — which would explain why infuseSelectAllToHeader is then finding multiple elements. Seems like the moral of the story is to check what $root is before proceeding.

I haven't been able to replicate the error locally though. :-(

Change 724690 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/GlobalPreferences@master] Check element structure when handling htmlform.enhance hook

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

Change 724690 merged by jenkins-bot:

[mediawiki/extensions/GlobalPreferences@master] Check element structure when handling htmlform.enhance hook

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

There haven't been any new errors since the above was merged. I'll check again in a few days, and then I think this is okay to close.

MusikAnimal subscribed.

No errors since the wmf.3 train finished rolling out on October 7.