Page MenuHomePhabricator

ConstraintParameterException from line 454 of WikibaseQualityConstraints/includes/ConstraintCheck/Helper/SparqlHelper.php
Closed, ResolvedPublic

Description

The following exception appears in the logs while hitting the following API URL.

https://www.wikidata.org/w/api.php?action=wbcheckconstraints&format=json&formatversion=2&uselang=en&id=Q1433459

2018-01-02 20:52:24 [WkvxCApAEDUAAFS2uOwAAAAW] mw1288 wikidatawiki 1.31.0-wmf.12 exception ERROR: [WkvxCApAEDUAAFS2uOwAAAAW] /w/api.php?action=wbcheckconstraints&format=json&formatversion=2&uselang=en&id=Q1433459
   WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterException from line 454 of /srv/mediawiki/php-1.31.0-wmf.12/extensions/WikibaseQualityConstraints/includes/ConstraintCheck/Helper/SparqlHelper.php: <span class="wbqc-role wbqc-role-constraint-parameter-value"><code><nowiki>[^{}[\]&lt;&gt;:]+</nowiki></code></span> is not a valid regular expression. {"exception_id":"WkvxCApAEDUAAFS2uOwAAAAW","exception_url":"/w/api.php?action=wbcheckconstraints&format=json&formatversion=2&uselang=en&id=Q1433459","caught_by":"mwe_handler"}
[Exception WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterException] (/srv/mediawiki/php-1.31.0-wmf.12/extensions/WikibaseQualityConstraints/includes/ConstraintCheck/Helper/SparqlHelper.php:454) <span class="wbqc-role wbqc-role-constraint-parameter-value"><code><nowiki>[^{}[\]&lt;&gt;:]+</nowiki></code></span> is not a valid regular expression.
  #0 /srv/mediawiki/php-1.31.0-wmf.12/extensions/WikibaseQualityConstraints/includes/ConstraintCheck/Helper/SparqlHelper.php(395): WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper->matchesRegularExpressionWithSparql(string, string)
  #1 /srv/mediawiki/php-1.31.0-wmf.12/includes/libs/objectcache/WANObjectCache.php(1168): Closure$WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper::matchesRegularExpression(array, integer, array, double)
  #2 /srv/mediawiki/php-1.31.0-wmf.12/includes/libs/objectcache/WANObjectCache.php(1107): WANObjectCache->doGetWithSetCallback(string, integer, Closure$WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper::matchesRegularExpression;1141, array, double)
  #3 /srv/mediawiki/php-1.31.0-wmf.12/includes/deferred/MWCallableUpdate.php(30): Closure$WANObjectCache::doGetWithSetCallback()
  #4 /srv/mediawiki/php-1.31.0-wmf.12/includes/deferred/DeferredUpdates.php(259): MWCallableUpdate->doUpdate()
  #5 /srv/mediawiki/php-1.31.0-wmf.12/includes/deferred/DeferredUpdates.php(210): DeferredUpdates::runUpdate(MWCallableUpdate, Wikimedia\Rdbms\LBFactoryMulti, string, integer)
  #6 /srv/mediawiki/php-1.31.0-wmf.12/includes/deferred/DeferredUpdates.php(131): DeferredUpdates::execute(array, string, integer)
  #7 /srv/mediawiki/php-1.31.0-wmf.12/includes/MediaWiki.php(897): DeferredUpdates::doUpdates(string)
  #8 /srv/mediawiki/php-1.31.0-wmf.12/includes/MediaWiki.php(719): MediaWiki->restInPeace(string, boolean)
  #9 [internal function]: Closure$MediaWiki::doPostOutputShutdown()
  #10 {main}

Event Timeline

Addshore created this task.Jan 2 2018, 8:53 PM
Restricted Application added subscribers: jeblad, Aklapper. · View Herald TranscriptJan 2 2018, 8:53 PM

I don’t really understand that stack trace – is the WANObjectCache refreshing itself asynchronously?

The exception thrown by matchesRegularExpressionWithSparql is intentional – but I guess it needs to be caught and stored in the getWithSetCallback closure. (Should be enough to just store the message.)

(By the way, the exception is because of the format constraint [^{}[\]<>:]+ on commons category (P373), which is legal in PCRE but not in java.util.regex.Pattern, where the unescaped [ begins a nested character class.)

Change 401724 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Catch ConstraintParameterException in SparqlHelper

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

Change 401724 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Catch ConstraintParameterException in SparqlHelper

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

@Addshore do you think the fix should be backported or is it enough to wait for the next regular deployment? (FWIW, the regex on “commons category” has been fixed in the meantime, but the same problem might occur on any other broken regex if they exist.)

Addshore added a subscriber: demon.Jan 4 2018, 5:07 PM

@Addshore do you think the fix should be backported or is it enough to wait for the next regular deployment? (FWIW, the regex on “commons category” has been fixed in the meantime, but the same problem might occur on any other broken regex if they exist.)

next deployment should be fine.
Unless @demon wants to push it out faster.

Change 402427 had a related patch set uploaded (by Chad; owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@wmf/1.31.0-wmf.15] Catch ConstraintParameterException in SparqlHelper

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

Change 402427 abandoned by Chad:
Catch ConstraintParameterException in SparqlHelper

Reason:
Nvm, will just wait til next week

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

Lucas_Werkmeister_WMDE closed this task as Resolved.Jan 11 2018, 11:53 AM
Lucas_Werkmeister_WMDE claimed this task.

The fix is deployed on Wikidata now. Please reopen if the error still pops up in the logs! (But the broken regex on the “Commons category” property has been fixed anyways.)

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