Page MenuHomePhabricator

Uncaught Error: Widget not found / Call to a member function getNsIndex() on null on CirrusSearch result page with internal error
Closed, ResolvedPublic2 Estimated Story Points

Description

When I visit https://en.wikipedia.beta.wmflabs.org/w/index.php?search=weak+power+law&title=Special%3ASearch&profile=advanced&fulltext=1&advancedSearch-current=%7B%22fields%22%3A%7B%22phrase%22%3A%22weak+power+law%22%7D%7D&ns0=1&ns1=1&ns2=1&ns3=1&ns4=1&ns5=1&ns6=1&ns7=1&ns8=1&ns9=1&ns10=1&ns11=1&ns12=1&ns13=1&ns14=1&ns15=1&ns100=1&ns101=1&ns108=1&ns109=1&ns118=1&ns119=1&ns190=1&ns191=1&ns446=1&ns447=1&ns482=1&ns483=1&ns710=1&ns711=1&ns810=1&ns811=1&ns828=1&ns829=1&ns2300=1&ns2301=1&ns2302=1&ns2303=1&ns5500=1&ns5501=1
I also see the error Uncaught Error: Widget not found in my JS console.

Backtrace:

from /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/Rescore/NamespacesFunctionScoreBuilder.php(54)
#0 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/Rescore/FunctionScoreChain.php(163): CirrusSearch\Search\Rescore\NamespacesFunctionScoreBuilder->__construct(CirrusSearch\HashSearchConfig, array, integer)
#1 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/Rescore/FunctionScoreChain.php(109): CirrusSearch\Search\Rescore\FunctionScoreChain->getImplementation(array)
#2 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/Rescore/RescoreBuilder.php(122): CirrusSearch\Search\Rescore\FunctionScoreChain->buildRescoreQuery()
#3 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/Rescore/RescoreBuilder.php(100): CirrusSearch\Search\Rescore\RescoreBuilder->buildRescoreQuery(array)
#4 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/SearchContext.php(531): CirrusSearch\Search\Rescore\RescoreBuilder->build()
#5 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Search/SearchRequestBuilder.php(98): CirrusSearch\Search\SearchContext->getRescore()
#6 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/Searcher.php(488): CirrusSearch\Search\SearchRequestBuilder->build()
#7 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/InterwikiSearcher.php(99): CirrusSearch\Searcher->buildSearch()
#8 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/CirrusSearch.php(316): CirrusSearch\InterwikiSearcher->getInterwikiResults(CirrusSearch\Search\SearchQuery)
#9 /srv/mediawiki/php-master/extensions/CirrusSearch/includes/CirrusSearch.php(269): CirrusSearch\CirrusSearch->searchTextReal(CirrusSearch\Search\SearchQuery)
#10 /srv/mediawiki/php-master/includes/search/SearchEngine.php(95): CirrusSearch\CirrusSearch->doSearchText(string)
#11 /srv/mediawiki/php-master/includes/search/SearchEngine.php(187): SearchEngine->{closure}()
#12 /srv/mediawiki/php-master/includes/search/SearchEngine.php(96): SearchEngine->maybePaginate(Closure)
#13 /srv/mediawiki/php-master/includes/specials/SpecialSearch.php(445): SearchEngine->searchText(string)
#14 /srv/mediawiki/php-master/includes/specials/SpecialSearch.php(229): SpecialSearch->showResults(string)
#15 /srv/mediawiki/php-master/includes/specialpage/SpecialPage.php(646): SpecialSearch->execute(NULL)
#16 /srv/mediawiki/php-master/includes/specialpage/SpecialPageFactory.php(1375): SpecialPage->run(NULL)
#17 /srv/mediawiki/php-master/includes/MediaWiki.php(309): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#18 /srv/mediawiki/php-master/includes/MediaWiki.php(925): MediaWiki->performRequest()
#19 /srv/mediawiki/php-master/includes/MediaWiki.php(547): MediaWiki->main()
#20 /srv/mediawiki/php-master/index.php(53): MediaWiki->run()
#21 /srv/mediawiki/php-master/index.php(46): wfIndexMain()
#22 /srv/mediawiki/w/index.php(3): require(string)
#23 {main}

On such pages the JS shouldn't be executed at all. The client perhaps should consider this as part of it's startup execution.

https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-2021.03.12?id=nYLlJXgBWKe2MTdRJMKN

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Reasonable chance this is because we are pulling ContLang from SearchConfig, ContLang was never configuration and might no longer be accessible that way.

Reasonable chance this is because we are pulling ContLang from SearchConfig, ContLang was never configuration and might no longer be accessible that way.

It was dropped recently in T245940: Hard-deprecate and remove $wgContLang, that's the immediate cause. The remote cause however, is a bug in CirrusSearch compounded by how the extension is (confusingly) re-using 'ContLang' in this context.

When the global $wgContLang was being replaced in extensions in preparation for the removal there was attempt to fix CirrusSearch gerrit:596254. See the discussion that ensued there. The patch was eventually abandoned because it was agreed at the time that CirrusSearch was not reading or the writing the value from/to the Global Config object. (I am not sure there was code change that changed that between then and now) but indeed it does at least read GlobalVarConfig::get( 'ContLang' ), as the current fatal error and the code in CirrusSearch\SearchConfig show.

This seems to be a misunderstanding in review, CirrusSearch uses ContLang both for local-wiki and cross-wiki behavior. When the wiki is remote Cirrus provides ContLang, but when the wiki is local it depends on the global variable to already exist. I suspect the misunderstanding revolves around how cirrus queries indices and returns results for any wiki in the cluster, and not only the local wiki being queried.

Change 672761 had a related patch set uploaded (by Ebernhardson; owner: Ebernhardson):
[operations/mediawiki-config@master] Expand CirrusSearchNamespaceWeights with explicit ns numbers

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

Change 672770 had a related patch set uploaded (by Ebernhardson; owner: Ebernhardson):
[mediawiki/extensions/CirrusSearch@master] Remove namespace name handling from NamespaceWeights

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

Change 672761 merged by jenkins-bot:
[operations/mediawiki-config@master] Expand CirrusSearchNamespaceWeights with explicit ns numbers

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

Mentioned in SAL (#wikimedia-operations) [2021-03-16T23:22:31Z] <krinkle@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Icd6635cb302cc, T277332 (duration: 00m 58s)

Change 672770 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Remove namespace name handling from NamespaceWeights

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