Page MenuHomePhabricator

PHP Warning: Invalid argument supplied for foreach() in SenseListChangeOpDeserializer
Open, Needs TriagePublic2 Estimated Story PointsPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: Invalid argument supplied for foreach()
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.10/extensions/WikibaseLexeme/src/Presentation/ChangeOp/Deserialization/SenseListChangeOpDeserializer.php(66)
#0 /srv/mediawiki/php-1.40.0-wmf.10/extensions/WikibaseLexeme/src/Presentation/ChangeOp/Deserialization/SenseListChangeOpDeserializer.php(66): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.40.0-wmf.10/extensions/WikibaseLexeme/src/Presentation/ChangeOp/Deserialization/LexemeChangeOpDeserializer.php(111): Wikibase\Lexeme\Presentation\ChangeOp\Deserialization\SenseListChangeOpDeserializer->createEntityChangeOp(array)
#2 /srv/mediawiki/php-1.40.0-wmf.10/extensions/Wikibase/repo/includes/ChangeOp/EntityChangeOpProvider.php(52): Wikibase\Lexeme\Presentation\ChangeOp\Deserialization\LexemeChangeOpDeserializer->createEntityChangeOp(array)
#3 /srv/mediawiki/php-1.40.0-wmf.10/extensions/Wikibase/repo/includes/Api/EditEntity.php(311): Wikibase\Repo\ChangeOp\EntityChangeOpProvider->newEntityChangeOp(string, array)
#4 /srv/mediawiki/php-1.40.0-wmf.10/extensions/Wikibase/repo/includes/Api/ModifyEntity.php(318): Wikibase\Repo\Api\EditEntity->getChangeOp(array, Wikibase\Lexeme\Domain\Model\Lexeme)
#5 /srv/mediawiki/php-1.40.0-wmf.10/includes/api/ApiMain.php(1902): Wikibase\Repo\Api\ModifyEntity->execute()
#6 /srv/mediawiki/php-1.40.0-wmf.10/includes/api/ApiMain.php(877): ApiMain->executeAction()
#7 /srv/mediawiki/php-1.40.0-wmf.10/includes/api/ApiMain.php(848): ApiMain->executeActionWithErrorHandling()
#8 /srv/mediawiki/php-1.40.0-wmf.10/api.php(90): ApiMain->execute()
#9 /srv/mediawiki/php-1.40.0-wmf.10/api.php(45): wfApiMain()
#10 /srv/mediawiki/w/api.php(3): require(string)
#11 {main}
Impact

Logstash warning for invalid request; no other issues, I think.

Notes

I randomly noticed this in Logstash – it’s easy enough to reproduce locally: call wbeditentity with a Lexeme ID and a data parameter like {"senses": null} (or {"forms": null}, in which case the error moves to FormListChangeOpDeserializer).

Event Timeline

Moving to Nov 2022 since that’s when I filed it, though I assume the bug has existed for years (whether it was ever triggered before is another question).

The referrer in Logstash is https://www.wikidata.org/wiki/Special:ApiSandbox, so someone was just experimenting, it seems.

Change 860013 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Check array type in list change op deserializers

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

Lucas_Werkmeister_WMDE added a subscriber: Michael.

Estimated at 2 story points by @Michael and me (ad-hoc estimation session).

Moving to tech verification since the change is currently going through gate-and-submit; can be verified next week (after the train rolls out) by making a wbeditentity request with id=L123 and data={"senses":null}. (IIRC, Beta doesn’t have a working logstash, so I don’t think we can verify it there.)

Change 860013 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Check array type in list change op deserializers

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

Meh, there’s another very similar error in logstash actually, that you can trigger with e.g. {"senses": [null]}. Let’s just treat that as the same task?

Change 863261 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Check array type some more in list change op deserializers

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

Change 863261 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Check array type some more in list change op deserializers

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