Page MenuHomePhabricator

Uncaught EntityContentTooBigException when trying to merge big Items
Open, Needs TriagePublicPRODUCTION ERROR

Description

When trying to merge Items that are too big, the EntityContentTooBigException is not caught, but shown to the user. We should show a meaningful error message instead.

Dashboard for these errors: https://logstash.wikimedia.org/goto/7e9dcccb2761199879c6ed6fb922ab93

Error
normalized_message
[{reqId}] {exception_url}   Wikibase\Lib\Store\EntityContentTooBigException:
exception.trace
from /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/lib/includes/Store/EntityContentDataCodec.php(160)
#0 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Content/EntityHandler.php(372): Wikibase\Lib\Store\EntityContentDataCodec->encodeEntity(Wikibase\DataModel\Entity\Item, string)
#1 /srv/mediawiki/php-1.40.0-wmf.1/includes/content/AbstractContent.php(174): Wikibase\Repo\Content\EntityHandler->serializeContent(Wikibase\Repo\Content\ItemContent, string)
#2 /srv/mediawiki/php-1.40.0-wmf.1/includes/Storage/PageEditStash.php(438): AbstractContent->serialize(string)
#3 /srv/mediawiki/php-1.40.0-wmf.1/includes/Storage/PageEditStash.php(263): MediaWiki\Storage\PageEditStash->getContentHash(Wikibase\Repo\Content\ItemContent)
#4 /srv/mediawiki/php-1.40.0-wmf.1/includes/Storage/DerivedPageDataUpdater.php(883): MediaWiki\Storage\PageEditStash->checkCache(Title, Wikibase\Repo\Content\ItemContent, User)
#5 /srv/mediawiki/php-1.40.0-wmf.1/includes/Storage/PageUpdater.php(335): MediaWiki\Storage\DerivedPageDataUpdater->prepareContent(User, MediaWiki\Storage\RevisionSlotsUpdate, boolean)
#6 /srv/mediawiki/php-1.40.0-wmf.1/includes/Storage/PageUpdater.php(890): MediaWiki\Storage\PageUpdater->prepareUpdate()
#7 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Store/Sql/WikiPageEntityStore.php(410): MediaWiki\Storage\PageUpdater->saveRevision(CommentStoreComment, integer)
#8 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Store/Sql/WikiPageEntityStore.php(269): Wikibase\Repo\Store\Sql\WikiPageEntityStore->saveEntityContent(Wikibase\Repo\Content\ItemContent, User, string, integer, boolean, array)
#9 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/lib/includes/Store/TypeDispatchingEntityStore.php(90): Wikibase\Repo\Store\Sql\WikiPageEntityStore->saveEntity(Wikibase\DataModel\Entity\Item, string, User, integer, boolean, array)
#10 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Interactors/ItemMergeInteractor.php(297): Wikibase\Lib\Store\TypeDispatchingEntityStore->saveEntity(Wikibase\DataModel\Entity\Item, string, User, integer, boolean, array)
#11 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Interactors/ItemMergeInteractor.php(275): Wikibase\Repo\Interactors\ItemMergeInteractor->saveItem(Wikibase\DataModel\Entity\Item, Wikibase\Lib\Summary, User, boolean, array)
#12 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Interactors/ItemMergeInteractor.php(177): Wikibase\Repo\Interactors\ItemMergeInteractor->attemptSaveMerge(Wikibase\DataModel\Entity\Item, Wikibase\DataModel\Entity\Item, string, User, boolean, array)
#13 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Api/MergeItems.php(157): Wikibase\Repo\Interactors\ItemMergeInteractor->mergeItems(Wikibase\DataModel\Entity\ItemId, Wikibase\DataModel\Entity\ItemId, DerivativeContext, array, string, boolean, array)
#14 /srv/mediawiki/php-1.40.0-wmf.1/extensions/Wikibase/repo/includes/Api/MergeItems.php(137): Wikibase\Repo\Api\MergeItems->mergeItems(Wikibase\DataModel\Entity\ItemId, Wikibase\DataModel\Entity\ItemId, array, string, boolean, array)
#15 /srv/mediawiki/php-1.40.0-wmf.1/includes/api/ApiMain.php(1900): Wikibase\Repo\Api\MergeItems->execute()
#16 /srv/mediawiki/php-1.40.0-wmf.1/includes/api/ApiMain.php(875): ApiMain->executeAction()
#17 /srv/mediawiki/php-1.40.0-wmf.1/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#18 /srv/mediawiki/php-1.40.0-wmf.1/api.php(90): ApiMain->execute()
#19 /srv/mediawiki/php-1.40.0-wmf.1/api.php(45): wfApiMain()
#20 /srv/mediawiki/w/api.php(3): require(string)
#21 {main}
Impact
  • merging is rather uncommon and requires special rights, so this does not happen too often, not a DDOS vector
  • it does add some very minor logspam
  • The first occurance seems to have been on 2022-08-08
  • All of these errors seem to originate from api.php, though the special page is also not reacting great
Acceptance criteria
  • Verify that no changes are done if a merge fails with an EntityTooBigException (IIRC, merging requires multiple edits to different Items - Is it possible to put all of them into some sort of "transaction"?)
  • The API responds with a proper Error instead of an unmitigated Exception
    • If we have any user interface that use this API: they react meaningful to that error
  • (potentially a separate task, to figure out when we start working on this): Special:Merge shows a helpful error message and is not be performing a partial operation
  • We have some tracking in place to record how often an operation is denied due to the Entity being too big
Notes

Details

Request URL
https://www.wikidata.org/w/api.php