Page MenuHomePhabricator

PHP Notice: Undefined index: taskType - causes Argument 1 passed to GrowthExperiments\NewcomerTasks\NewcomerTasksChangeTagsManager::apply() must be of the type string, null given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Notice: Undefined index: taskType
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.1/extensions/GrowthExperiments/includes/VisualEditorHooks.php(140)
#0 /srv/mediawiki/php-1.39.0-wmf.1/extensions/GrowthExperiments/includes/VisualEditorHooks.php(140): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.39.0-wmf.1/includes/HookContainer/HookContainer.php(160): GrowthExperiments\VisualEditorHooks->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#2 /srv/mediawiki/php-1.39.0-wmf.1/extensions/VisualEditor/includes/VisualEditorHookRunner.php(75): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#3 /srv/mediawiki/php-1.39.0-wmf.1/extensions/VisualEditor/includes/ApiVisualEditorEdit.php(541): MediaWiki\Extension\VisualEditor\VisualEditorHookRunner->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#4 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(1893): MediaWiki\Extension\VisualEditor\ApiVisualEditorEdit->execute()
#5 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(870): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(841): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.39.0-wmf.1/api.php(90): ApiMain->execute()
#8 /srv/mediawiki/php-1.39.0-wmf.1/api.php(45): wfApiMain()
#9 /srv/mediawiki/w/api.php(3): require(string)
#10 {main}

Seems likely to be causing:

normalized_message
[{reqId}] {exception_url}   TypeError: Argument 1 passed to GrowthExperiments\NewcomerTasks\NewcomerTasksChangeTagsManager::apply() must be of the type string, null given, called in /srv/mediawiki/php-1.39.0-wmf.1/extensions/GrowthExperiments/includes/Vis
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.1/extensions/GrowthExperiments/includes/NewcomerTasks/NewcomerTasksChangeTagsManager.php(71)
#0 /srv/mediawiki/php-1.39.0-wmf.1/extensions/GrowthExperiments/includes/VisualEditorHooks.php(140): GrowthExperiments\NewcomerTasks\NewcomerTasksChangeTagsManager->apply(NULL, integer, User)
#1 /srv/mediawiki/php-1.39.0-wmf.1/includes/HookContainer/HookContainer.php(160): GrowthExperiments\VisualEditorHooks->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#2 /srv/mediawiki/php-1.39.0-wmf.1/extensions/VisualEditor/includes/VisualEditorHookRunner.php(75): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#3 /srv/mediawiki/php-1.39.0-wmf.1/extensions/VisualEditor/includes/ApiVisualEditorEdit.php(541): MediaWiki\Extension\VisualEditor\VisualEditorHookRunner->onVisualEditorApiVisualEditorEditPostSave(MediaWiki\Page\PageIdentityValue, User, string, array, array, array, array)
#4 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(1893): MediaWiki\Extension\VisualEditor\ApiVisualEditorEdit->execute()
#5 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(870): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.39.0-wmf.1/includes/api/ApiMain.php(841): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.39.0-wmf.1/api.php(90): ApiMain->execute()
#8 /srv/mediawiki/php-1.39.0-wmf.1/api.php(45): wfApiMain()
#9 /srv/mediawiki/w/api.php(3): require(string)
#10 {main}
Impact

Unclear.

Notes

2 of these in 1.39.0-wmf.1 (T300203).

Details

Request URL
https://ru.wikipedia.org/w/api.php
Related Changes in Gerrit:

Event Timeline

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

The code in GrowthExperiments/includes/VisualEditorHooks.php at line 140 should only be reached if we have some data sent from the client-side, and one of those things is a field in the payload called taskType. Line 140 is complaining that this isn't set. In line 107 we call getDataFromApiRequest which should only return if there is a JSON blob that matches a data structure that we expect (we don't check for taskType, though).

Is it possible that the JavaScript file for this feature wasn't updated for these two users (who are logged-in), and so they posted incomplete payload which then caused the error? @brennen I guess this would be possible if they were mid-edit while the server-side files were synced?

Is it possible that the JavaScript file for this feature wasn't updated for these two users (who are logged-in), and so they posted incomplete payload which then caused the error? @brennen I guess this would be possible if they were mid-edit while the server-side files were synced?

Maybe? Seems plausible since it hasn't recurred since 18:13 UTC.

Is it possible that the JavaScript file for this feature wasn't updated for these two users (who are logged-in), and so they posted incomplete payload which then caused the error?

Client-side changes take 5-10 minutes to propagate to new browsing sessions. There is no limit to how long an existing browser tab can stay open and continue to use the running code from that process. If this was a breaking change then it should probably have been done in two stages such that they are deployed in separate trains, or by deploying the the prep stage through a backport deploy.

As for this task, the API is public and should not cause an application-level error regardless of what the HTTP endpoint receives from the outside world. However if this is indeed not "possible" for supported use cases, then the fix might be as simple as correctly discarding invalid input and/or ensuring internal methods are only called with internally created data structures based on input instead of passed through from external input.

Is it possible that the JavaScript file for this feature wasn't updated for these two users (who are logged-in), and so they posted incomplete payload which then caused the error? @brennen I guess this would be possible if they were mid-edit while the server-side files were synced?

Maybe? Seems plausible since it hasn't recurred since 18:13 UTC.

OK, thanks for checking.

Is it possible that the JavaScript file for this feature wasn't updated for these two users (who are logged-in), and so they posted incomplete payload which then caused the error?

Client-side changes take 5-10 minutes to propagate to new browsing sessions. There is no limit to how long an existing browser tab can stay open and continue to use the running code from that process. If this was a breaking change then it should probably have been done in two stages such that they are deployed in separate trains, or by deploying the the prep stage through a backport deploy.

Yeah, that would have been a good idea.

As for this task, the API is public and should not cause an application-level error regardless of what the HTTP endpoint receives from the outside world. However if this is indeed not "possible" for supported use cases, then the fix might be as simple as correctly discarding invalid input and/or ensuring internal methods are only called with internally created data structures based on input instead of passed through from external input.

That's the remaining actionable item, here, I think. We should make sure that 'taskType' is set in the data structure and return an error otherwise.

kostajh triaged this task as Medium priority.

Change 773216 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] VisualEditorHooks: Get task type ID from plugin data

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

Change 773216 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] VisualEditorHooks: Get task type ID from plugin data

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