Page MenuHomePhabricator

ParameterTypeException: Bad value for parameter $taskType: must be a ImageRecommendationBaseTaskType
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\ParameterTypeException: Bad value for parameter $taskType: must be a GrowthExperiments\NewcomerTasks\TaskType\ImageRecommendationBaseTaskType
error.stack_trace
from /srv/mediawiki/php-1.41.0-wmf.16/vendor/wikimedia/assert/src/Assert.php(105)
#0 /srv/mediawiki/php-1.41.0-wmf.16/extensions/GrowthExperiments/includes/Api/ApiInvalidateImageRecommendation.php(69): Wikimedia\Assert\Assert::parameterType(array, NULL, string)
#1 /srv/mediawiki/php-1.41.0-wmf.16/includes/api/ApiMain.php(1915): GrowthExperiments\Api\ApiInvalidateImageRecommendation->execute()
#2 /srv/mediawiki/php-1.41.0-wmf.16/includes/api/ApiMain.php(892): ApiMain->executeAction()
#3 /srv/mediawiki/php-1.41.0-wmf.16/includes/api/ApiMain.php(863): ApiMain->executeActionWithErrorHandling()
#4 /srv/mediawiki/php-1.41.0-wmf.16/api.php(95): ApiMain->execute()
#5 /srv/mediawiki/php-1.41.0-wmf.16/api.php(48): wfApiMain()
#6 /srv/mediawiki/w/api.php(3): require(string)
#7 {main}
Impact
Notes

Looks like getTaskTypes() can return empty array, as acknowledged by getTaskTypes()[…] ?? null in the code, but that means the fatal error is "expected" which needs to be addressed somehow.

Details

Request URL
https://en.wikipedia.org/w/api.php?action=growthinvalidateimagerecommendation&errorformat=*&errorsuselocal=*&format=*&formatversion=*

Event Timeline

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

In T341150: Ensure growthimagesuggestiondata API works on all Wikipedias, we added image-recommendation and section-image-recommendation to the NewcomerTasks.json config file on all Wikipedias. This enabled ApiQueryImageSuggestionData (which had a similar error, cf. T337330), but not ApiInvalidateImageRecommendation, because the invalidation API only checks ConfigurationLoader::getTaskTypes, not ConfigurationLoader::getDisabledTaskTypes as well (which happens in ApiQueryImageSuggestionData). Essentially, the invalidation API requires the image recommendation task types to be enabled to work properly.

Since the Android app plans to use the image suggestions feature and re-use the APIs Growth team has, we need to make the invalidation API working even when the task is disabled in the configuration. We can do that by merging ConfigurationLoader::getTaskTypes and ConfigurationLoader::getDisabledTaskTypes in the API, similar to ApiQueryImageSuggestionData.

In T341150: Ensure growthimagesuggestiondata API works on all Wikipedias, we added image-recommendation and section-image-recommendation to the NewcomerTasks.json config file on all Wikipedias. This enabled ApiQueryImageSuggestionData (which had a similar error, cf. T337330), but not ApiInvalidateImageRecommendation, because the invalidation API only checks ConfigurationLoader::getTaskTypes, not ConfigurationLoader::getDisabledTaskTypes as well (which happens in ApiQueryImageSuggestionData). Essentially, the invalidation API requires the image recommendation task types to be enabled to work properly.

Since the Android app plans to use the image suggestions feature and re-use the APIs Growth team has, we need to make the invalidation API working even when the task is disabled in the configuration. We can do that by merging ConfigurationLoader::getTaskTypes and ConfigurationLoader::getDisabledTaskTypes in the API, similar to ApiQueryImageSuggestionData.

Actually, ApiInvalidateImageRecommendation checks whether the invalidated article is in the user's task set. That definitely won't happen now with Android app (as the task is not enabled, so users don't have access to it through Growth features), and it wouldn't happen even if the task was enabled everywhere (because the user might not have it enabled at any given time).

How should invalidation for Android app be handled?

Change 939645 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] ApiInvalidateImageRecommendation: Error out nicely if task type is not available

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

Change 939645 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] ApiInvalidateImageRecommendation: Error out nicely if task type is not available

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

Urbanecm_WMF triaged this task as Medium priority.

The error is resolved by the patch above; the T341813#9026754 question will be discussed as part of T341150.

Etonkovidova subscribed.

The last time stamp for the error- Jul 19, 2023 @ 19:14:47.592 (logstash link).