Page MenuHomePhabricator

GetEntities, DivergingEntityIdException: Revision 1072801264 belongs to Q354111 instead of expected d:Q354111
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.35.0-wmf.16

message
Revision 1072801264 belongs to Q354111 instead of expected d:Q354111

More examples:

  • Wikibase\Lib\Store\DivergingEntityIdException from line 154 of /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/Sql/WikiPageEntityRevisionLookup.php: Revision 835602834 belongs to Q55838615 instead of expected d:Q55838615
  • Wikibase\DataModel\Services\Lookup\EntityLookupException from line 45 of /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/RevisionBasedEntityLookup.php: Revision 1089579846 belongs to P301 instead of expected Property:P301

Impact

  • Doesn't seem too new, but there are certainly a lot more DivergingEntityIdException errors in the last few days
  • It would be nice if we at least somehow "collect" those in Kibana/Logstash under the same message string by replacing the IDs with placeholders?

Notes

Search reproduction: https://www.wikidata.org/w/api.php?action=wbsearchentities&format=json&limit=50&continue=0&language=it&uselang=it&search=Property%3AP301&type=property
getentities reproduction: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=d:Q64

Solution

In our APIs we need to check that the entity id parsed is for a valid defined entity source / repo.
I say entitysource/repo as at the time of writing this we have not yet killed repo based federation to switch to entity sourced, but that will likely happen before this task is picked up.

Details

Request ID
XjQqhwpAIDkAAJuszE8AAACV
Request URL
https://www.wikidata.org/w/api.php
Stack Trace
exception.trace
#0 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/data-access/src/ByTypeDispatchingEntityRevisionLookup.php(54): Wikibase\Lib\Store\Sql\WikiPageEntityRevisionLookup->getEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#1 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/TypeDispatchingEntityRevisionLookup.php(54): Wikibase\DataAccess\ByTypeDispatchingEntityRevisionLookup->getEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#2 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(104): Wikibase\Lib\Store\TypeDispatchingEntityRevisionLookup->getEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#3 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(87): Wikibase\Lib\Store\CachingEntityRevisionLookup->fetchEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#4 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(104): Wikibase\Lib\Store\CachingEntityRevisionLookup->getEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#5 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/lib/includes/Store/CachingEntityRevisionLookup.php(87): Wikibase\Lib\Store\CachingEntityRevisionLookup->fetchEntityRevision(Wikibase\DataModel\Entity\ItemId, integer, string)
#6 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/repo/includes/Api/GetEntities.php(275): Wikibase\Lib\Store\CachingEntityRevisionLookup->getEntityRevision(Wikibase\DataModel\Entity\ItemId)
#7 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/repo/includes/Api/GetEntities.php(257): Wikibase\Repo\Api\GetEntities->getEntityRevision(Wikibase\DataModel\Entity\ItemId, boolean)
#8 /srv/mediawiki/php-1.35.0-wmf.16/extensions/Wikibase/repo/includes/Api/GetEntities.php(136): Wikibase\Repo\Api\GetEntities->getEntityRevisionsFromEntityIds(array, boolean)
#9 /srv/mediawiki/php-1.35.0-wmf.16/includes/api/ApiMain.php(1603): Wikibase\Repo\Api\GetEntities->execute()
#10 /srv/mediawiki/php-1.35.0-wmf.16/includes/api/ApiMain.php(539): ApiMain->executeAction()
#11 /srv/mediawiki/php-1.35.0-wmf.16/includes/api/ApiMain.php(510): ApiMain->executeActionWithErrorHandling()
#12 /srv/mediawiki/php-1.35.0-wmf.16/api.php(78): ApiMain->execute()
#13 /srv/mediawiki/w/api.php(3): require(string)
#14 {main}

Event Timeline

So, the mediainfo log entries relate to the issue of mediainfo entities changing their ID (as they use the id of the page)
That is essentially T231276, looks like perhaps that still logs but shouldn't?

As for the property and item related logs that appear on wikidata, it would appear this ends up happening as string such as "Property:P123" and "d:Q123" can correctly be parsed as item or property ids in EntityIdSearchHelper, as this is the format used for prefixed entity ids that we don't actually use anywhere..
I guess the expected behaviour currently would be that if foreign ids are parsed, not to continue processing them through the rest of the search code.

Nothing to worry about really, but we should get rid of this log spam :)

I have split the commons error out into T244207: Revision 386521405 belongs to M43864745 instead of expected M79277318 has it has a different cause, profile and fix to the wikidata ones.

Addshore renamed this task from DivergingEntityIdException: Revision 1072801264 belongs to Q354111 instead of expected d:Q354111 to GetEntities, DivergingEntityIdException: Revision 1072801264 belongs to Q354111 instead of expected d:Q354111.Feb 4 2020, 9:24 AM
Addshore updated the task description. (Show Details)

Change 574496 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] GetEntities: Handle unknown repo in entity ids

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

Change 574497 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] EntityIdSearchHelper: Handle unknown repo in entity ids

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

I addressed the problem mentioned above, but this potentially affects all places where we: a) Take user supplied entity ids b) check EntityLookup::hasEntityId on them and b) then try to fetch the entity.

Maybe we should make EntityLookup::hasEntityId (or a new method) aware of this? :/

Change 574496 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] GetEntities: Handle unknown repo in entity ids

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

Change 574497 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] EntityIdSearchHelper: Handle unknown repo in entity ids

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