Page MenuHomePhabricator

Wikibase: $idSerialization must match /^Q[1-9]\d{0,9}\z/i
Closed, ResolvedPublicPRODUCTION ERROR

Description

 /w/api.php?action=wbcheckconstraints&format=json&uselang=en&id=P3212
InvalidArgumentException from line 39 of /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/vendor/wikibase/data-model/src/Entity/ItemId.php: $idSerialization must match /^Q[1-9]\d{0,9}\z/i
Wikibase: $idSerialization must match /^Q[1-9]\d{0,9}\z/i
#0 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/vendor/wikibase/data-model/src/Entity/ItemId.php(27): Wikibase\DataModel\Entity\ItemId->assertValidIdFormat(string)
#1 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php(110): Wikibase\DataModel\Entity\ItemId->__construct(string)
#2 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/Helper/ConnectionCheckerHelper.php(65): WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper->parseItemIdSnakValues(array)
#3 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/Checker/InverseChecker.php(109): WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper->findStatement(Wikibase\DataModel\Statement\StatementList, string, array)
#4 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(237): WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker->checkConstraint(Wikibase\DataModel\Statement\Statement, WikibaseQuality\ConstraintReport\Constraint, Wikibase\DataModel\Entity\Property)
#5 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(216): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->getCheckResultFor(Wikibase\DataModel\Statement\Statement, WikibaseQuality\ConstraintReport\Constraint, Wikibase\DataModel\Entity\Property)
#6 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(181): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->checkConstraintsForStatementOnEntity(array, Wikibase\DataModel\Entity\Property, Wikibase\DataModel\Statement\Statement)
#7 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(147): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->checkStatement(Wikibase\DataModel\Entity\Property, Wikibase\DataModel\Statement\Statement, NULL)
#8 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(104): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->checkEveryStatement(Wikibase\DataModel\Entity\Property, NULL)
#9 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/api/CheckConstraints.php(191): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->checkAgainstConstraintsOnEntityId(Wikibase\DataModel\Entity\PropertyId, NULL)
#10 /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/extensions/Constraints/api/CheckConstraints.php(179): WikibaseQuality\ConstraintReport\Api\CheckConstraints->checkItems(array, NULL)
#11 /srv/mediawiki/php-1.30.0-wmf.9/includes/api/ApiMain.php(1583): WikibaseQuality\ConstraintReport\Api\CheckConstraints->execute()
#12 /srv/mediawiki/php-1.30.0-wmf.9/includes/api/ApiMain.php(546): ApiMain->executeAction()
#13 /srv/mediawiki/php-1.30.0-wmf.9/includes/api/ApiMain.php(517): ApiMain->executeActionWithErrorHandling()
#14 /srv/mediawiki/php-1.30.0-wmf.9/api.php(94): ApiMain->execute()
#15 /srv/mediawiki/w/api.php(3): include(string)
#16 {main}

Started around the same time, similar to T170597: Wikidata/extensions/Constraints: InvalidArgumentException:$itemId must be either ItemId or string

Event Timeline

thcipriani triaged this task as Unbreak Now! priority.Jul 13 2017, 4:40 PM

UBN since I added as a train blocker.

Added as blocker as this appears to be a new log message with wmf.9.

This looks like constraint checker encountering some bad data. I've sighted some bad IDs on Wikidata (e.g. see T167565) and it looks like ConnectionCheckerHelper does not catch exceptions on bad data (which, being checker, it probably should either there or upstream).

thcipriani lowered the priority of this task from Unbreak Now! to Medium.Jul 13 2017, 6:54 PM

Removed as train blocker, seems to have been happening pre 1.30.0-wmf.9, sorry for the noise

I notice two things:

  1. ConnectionCheckerHelper::parseItemIdSnakValues processes values that can come from the constraint parameters, which are currently almost free-form text, so it definitely should catch parse exceptions. My bad – sorry.
  2. In this stack trace, however, its argument comes from InverseChecker, which calls it with $entity->getId()->getSerialization() – so the string is a valid entity ID, otherwise we wouldn’t have an $entity object. However, it could be a property instead of an item – I suspect that’s the problem here.

How urgently do you need a fix for this? A simple fix that isn’t correct but at least doesn’t throw an exception shouldn’t be hard.

Change 365090 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Fix exception thrown from ConnectionCheckerHelper

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

Okay, the above change is a quick’n’dirty fix if you need it. Should apply cleanly on top of the currently deployed code.

I’ll create a separate task for the real solution.

@LucasWerkmeister can you file a ticket for the underlying problem you mentioned in the commit message? Thanks!

Change 365090 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Fix exception thrown from ConnectionCheckerHelper

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

I don’t think anything has been backported for this issue, so I guess we’ll know for sure later today when the new build is deployed. (Where “we” is someone who has access to the logs, i. e. not me :) )

In logstash, the last trace matching idSerialization is 2017-07-20T16:56:19 and had:

/w/api.php?action=wbcheckconstraints&format=json&uselang=en&id=P3212   InvalidArgumentException from line 39 of /srv/mediawiki/php-1.30.0-wmf.9/extensions/Wikidata/vendor/wikibase/data-model/src/Entity/ItemId.php: $idSerialization must match /^Q[1-9]\d{0,9}\z/i

That seems to match with a rollback of wikidata to wmf.10

17:16	<demon@tin>	rebuilt wikiversions.php and synchronized wikiversions files: wikidata back to wmf.10
Lucas_Werkmeister_WMDE claimed this task.

I think this is definitely resolved now, since we moved to constraint statements (T169647: Enable constraint statements on Wikidata), which removed all the constraints with invalid parameters. This also means that the fix for this issue was deployed (both the quick fix, I6bc6711e00, and the proper solution, Iac23aa1443, are part of the wmf/1.30.0-wmf.10 branch in the WBQC repository).

Thanks for the log confirmation, @hashar :)

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:10 PM