Page MenuHomePhabricator

Language fallback for search can fail when rescore profile doesn't exist on target wiki
Closed, ResolvedPublic

Description

Example failure: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=sistema%20parlamentario%20con%20sede%20de%20gobierno&srenablerewrites=yes&srinterwiki=1
Log message: https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2018.01.02/mediawiki/?id=AWC4yTHthTduSC7pBP2q
Stack trace:

#0 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/Search/RescoreBuilders.php(76): CirrusSearch\Search\RescoreBuilder->getSupportedProfile(string)
#1 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/Search/SearchContext.php(599): CirrusSearch\Search\RescoreBuilder->__construct(CirrusSearch\Search\SearchContext)
#2 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/Search/SearchRequestBuilder.php(109): CirrusSearch\Search\SearchContext->getRescore()
#3 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/Searcher.php(516): CirrusSearch\Search\SearchRequestBuilder->build()
#4 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/Searcher.php(360): CirrusSearch\Searcher->buildSearch()
#5 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/CirrusSearch.php(388): CirrusSearch\Searcher->searchText(string, boolean)
#6 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/CirrusSearch.php(303): CirrusSearch->searchTextReal(string, CirrusSearch\HashSearchConfig, boolean)
#7 /srv/mediawiki/php-1.31.0-wmf.12/extensions/CirrusSearch/includes/CirrusSearch.php(183): CirrusSearch->searchTextSecondTry(string, Status)
#8 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiQuerySearch.php(97): CirrusSearch->searchText(string)
#9 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiQuerySearch.php(43): ApiQuerySearch->run()
#10 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiQuery.php(253): ApiQuerySearch->execute()
#11 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiMain.php(1582): ApiQuery->execute()
#12 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiMain.php(544): ApiMain->executeAction()
#13 /srv/mediawiki/php-1.31.0-wmf.12/includes/api/ApiMain.php(515): ApiMain->executeActionWithErrorHandling()
#14 /srv/mediawiki/php-1.31.0-wmf.12/api.php(94): ApiMain->execute()
#15 /srv/mediawiki/w/api.php(3): include(string)
#16 {main}

It looks like what's happening here is SearchApi.php trait is setting the default SearchEngine::FT_QUERY_INDEP_PROFILE_TYPE based on the local wiki configuration, and when loading the config and querying the other wiki the profile doesn't exist. First level fix should probably be to only set the profile if a user explicitly provided one. That only solves the most obvious occurance of the problem though, a user explicitly setting the qiprofile can still experience the error. We might need to have a way for the non-existent profile to fallback to the default profile instead of bailing out.

Details

Related Gerrit Patches:
mediawiki/extensions/CirrusSearch : masterUse target wiki config when checking rescore profile

Event Timeline

Restricted Application added a project: Discovery. · View Herald TranscriptJan 2 2018, 9:53 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I remember that it's due to the type of API param we use. When setting an array as ApiBase::PARAM_TYPE a default must be provided IIRC.
The use of arrays was a way to expose the list of possible profiles to use but the drawback was that the API would fail if you provide an unknown param. I think this is wrong, I agree, cirrus should be able to know if a profile was explicitly set by the user.

Alternatively one quick fix could be for cirrus to not fail in case of missing rescore profile by checking the target wiki config instead of the local one. Looking at the code we check the wrong config object.

Change 401703 had a related patch set uploaded (by DCausse; owner: DCausse):
[mediawiki/extensions/CirrusSearch@master] Use target wiki config when checking rescore profile

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

Change 401703 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Use target wiki config when checking rescore profile

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

debt closed this task as Resolved.Feb 26 2018, 3:36 PM
debt claimed this task.