Page MenuHomePhabricator

DomainException / NullResult holds no constraint
Closed, ResolvedPublicPRODUCTION ERROR

Description

Spotted in production:

DomainException: NullResult holds no constraint

Urls all seem of the same style, differing Q values

/w/api.php?action=wbcheckconstraints&format=json&uselang=en&id=Qxxxxx

Stacktrace:

#0 /srv/mediawiki/php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(577): WikibaseQuality\ConstraintReport\ConstraintCheck\Result\NullResult->getConstraint()
#1 [internal function]: Closure$WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker::sortResult(WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult, WikibaseQuality\ConstraintReport\ConstraintCheck\Result\NullResult)
#2 /srv/mediawiki/php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(595): uasort(array, Closure$WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker::sortResult;2735)
#3 /srv/mediawiki/php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php(134): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->sortResult(array)
#4 /srv/mediawiki/php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/api/CheckConstraints.php(235): WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker->checkAgainstConstraintsOnEntityId(Wikibase\DataModel\Entity\ItemId, NULL, array)
#5 /srv/mediawiki/php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/api/CheckConstraints.php(214): WikibaseQuality\ConstraintReport\Api\CheckConstraints->checkItems(array, NULL)
#6 /srv/mediawiki/php-1.31.0-wmf.5/includes/api/ApiMain.php(1582): WikibaseQuality\ConstraintReport\Api\CheckConstraints->execute()
#7 /srv/mediawiki/php-1.31.0-wmf.5/includes/api/ApiMain.php(544): ApiMain->executeAction()
#8 /srv/mediawiki/php-1.31.0-wmf.5/includes/api/ApiMain.php(515): ApiMain->executeActionWithErrorHandling()
#9 /srv/mediawiki/php-1.31.0-wmf.5/api.php(94): ApiMain->execute()
#10 /srv/mediawiki/w/api.php(3): include(string)
#11 {main}

Event Timeline

Ah, I didn’t think about that. Happens when you have two identical statements (same main snak hash) with a property that doesn’t have any constraints. We add a NullResult for each of them so they still appear in the API response, we try to sort all the results (including the NullResults), the snaks are identical so the comparer tries to compare the constraints, boom. Fix coming up.

Change 386597 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Fix sorting of NullResults

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

One example item where this happens is Q37038369 (ApiSandbox), due to its two “source of energy: coal” statements. (Found with this query.)

Correction: this happens on any item with two identical statements, regardless of whether the property has constraints or not. (Another example: Denmark (Q35)’s head of government (P​6).) So this is probably a lot more common than I first thought.

Change 386597 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Fix sorting of NullResults

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

Lucas_Werkmeister_WMDE added a subscriber: Ladsgroup.

@Ladsgroup will backport during today’s Morning SWAT (18:00–19:00 UTC).

Change 386653 had a related patch set uploaded (by Ladsgroup; owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@wmf/1.31.0-wmf.5] Fix sorting of NullResults

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

Change 386654 had a related patch set uploaded (by Ladsgroup; owner: Amir Sarabadani):
[mediawiki/extensions/Wikidata@wmf/1.31.0-wmf.5] Fix sorting of NullResults

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

Change 386654 merged by jenkins-bot:
[mediawiki/extensions/Wikidata@wmf/1.31.0-wmf.5] Fix sorting of NullResults

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

Mentioned in SAL (#wikimedia-operations) [2017-10-26T18:51:20Z] <ladsgroup@tin> Synchronized php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/includes/ConstraintCheck/DelegatingConstraintChecker.php: Fix sorting of NullResults (T179038) (duration: 01m 04s)

Mentioned in SAL (#wikimedia-operations) [2017-10-26T18:52:45Z] <ladsgroup@tin> Synchronized php-1.31.0-wmf.5/extensions/Wikidata/extensions/Constraints/tests/phpunit/DelegatingConstraintCheckerTest.php: Fix sorting of NullResults (T179038) (duration: 00m 49s)

Change 386653 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@wmf/1.31.0-wmf.5] Fix sorting of NullResults

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

Seems to be fixed, thanks @Ladsgroup! Please reopen if there are any new log errors.

Mentioned in SAL (#wikimedia-operations) [2017-10-26T19:12:24Z] <ladsgroup@tin> Synchronized php-1.31.0-wmf.5/extensions/WikibaseQualityConstraints/tests/phpunit/DelegatingConstraintCheckerTest.php: Fix sorting of NullResults (T179038) (duration: 00m 50s)

Mentioned in SAL (#wikimedia-operations) [2017-10-26T19:14:05Z] <ladsgroup@tin> Synchronized php-1.31.0-wmf.5/extensions/WikibaseQualityConstraints/includes/ConstraintCheck/DelegatingConstraintChecker.php: Fix sorting of NullResults (T179038) (duration: 00m 49s)

Note: the backport was reverted due to (hopefully) unrelated problems (T179156), but since we could already see that it fixed the problem during the short time it was deployed, I don’t think we need to reopen this task – we can just wait until either the backport or the regular commit is deployed.

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