soweego icon indicating copy to clipboard operation
soweego copied to clipboard

Investigate how to intercept constraint check reports

Open marfox opened this issue 6 years ago • 6 comments

A very useful signal of a wrong link is when the constraint check Wikibase extension raises a warning on a given identifier statement.

See the screenshot for an example: Screen Shot 2019-04-03 at 16 19 00

It would be optimal to programmatically intercept these warnings and skip/delete the identifier during the upload process.

Pointers:

  • https://www.wikidata.org/wiki/Help:Property_constraints_portal
  • https://www.wikidata.org/wiki/Special:ConstraintReport
  • https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations

marfox avatar Apr 03 '19 14:04 marfox

The wbcheckconstraints Wikidata API action should be what we need: https://www.wikidata.org/w/api.php?action=help&modules=wbcheckconstraints

marfox avatar Apr 08 '19 13:04 marfox

Recent breaking change on this API action: https://lists.wikimedia.org/pipermail/wikidata/2019-April/012910.html

marfox avatar Apr 17 '19 13:04 marfox

This sounds like the tool we need: https://github.com/wmde/wikidata-constraints-violation-checker

marfox avatar Aug 19 '21 11:08 marfox

This sounds like the tool we need: https://github.com/wmde/wikidata-constraints-violation-checker

Checked it out. The answer is: no, it just shows counts of constraint violations. We need fine-grained control on specific statements.

We should use the claimid parameter of the wbcheckconstraints API endpoint, instead: it expects a claim GUID, though.

marfox avatar Aug 24 '21 10:08 marfox

it expects a claim GUID, though.

We can retrieve it in the debug logs of our bot, only when a new claim is created (doesn't apply to references).

We should get the id key of the Wikidata API JSON response. For instance:

2021-08-19 15:27:19,997 [DEBUG] wikidata_bot._add #809 - Added claim: {'mainsnak': {'snaktype': 'value', 'property': 'P5431', 'datatype': 'external-id', 'datavalue': {'value': '33d5bc21', 'type': 'string'}}, 'type': 'statement', 'id': 'Q3779971$3162884b-c804-44b1-9972-eb022001f68e', 'rank': 'normal'}

GUID = Q3779971$3162884b-c804-44b1-9972-eb022001f68e

Finally, call https://www.wikidata.org/w/api.php?action=wbcheckconstraints&claimid=Q3779971$3162884b-c804-44b1-9972-eb022001f68e

marfox avatar Aug 24 '21 10:08 marfox

Waiting for https://phabricator.wikimedia.org/T289710

marfox avatar Aug 26 '21 09:08 marfox