Page MenuHomePhabricator

Pywikibot to detect and correctly handle edits that trigger abusefilter rules
Closed, ResolvedPublic

Description

AbuseFilter errors and warnings during page save are not detected as a specific type of failure. The closed task T57293#1921011 includes an example of Pywikibot hitting an edit filter and the resulting failure.

Often Abusefilter rules allow an action to be re-tried, and other abusefilter rules can cause a block if repeatedly ignored.

When an abuse filter has been encountered, the API error codes should be decoded, reported nicely to the user, and possibly allow re-try if the abusefilter rule allows that.

Also Pywikibot may need to alert the user that it may be about to trigger a block action if it continues to perform the same type of edit.

Familiarisation:

A good way to start familiarising yourself with this project proposal is to set up a MediaWiki installation on your computer, with the abuse filter extension, set up some abuse filter rules on your own wiki, using various abuse rule options, and then

  1. trigger them manually with a normal browser
  2. trigger them automatically with a MediaWiki client, preferably Pywikibot.

Look at https://www.mediawiki.org/wiki/Special:AbuseFilter and https://en.wikipedia.org/wiki/Special:AbuseFilter to see what rules big wikis create, and why, and think about how an automated MediaWiki client should respond when it hits one of those rules.

Mentors: @jayvdb
Co-mentor: @AbdealiJK
Microtask: T56551, T103284, T103736
Skills required: Python, Pywikibot, Mediawiki Extension Abusefilter

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
jayvdb raised the priority of this task from to Needs Triage.Jan 1 2015, 6:57 AM
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb subscribed.

Logging here some info:

(Pdb) result['edit']
{u'info': u'Hit AbuseFilter: Test filter', u'code': u'abusefilter-disallowed', u'warning': u'This action has been automatically identified as harmful, and therefore disallowed.\nIf you believe your action was constructive, please inform an administrator of what you were trying to do.\nA brief description of the abuse rule which your action matched is: Test filter', u'result': u'Failure'}

BTW, this was tested on wikisource, I hope all wiki expose the same response ...

I tried to change the filter:
(Pdb) result['edit']
{u'info': u'Hit AbuseFilter: Test filter', u'code': u'test message', u'warning': u'<test message>', u'result': u'Failure'}
'info' seems fixed, 'code' can be customised by filter editor.

This task is to correctly detect edit filter, use a new exception, and also allow retry when the edit filter permits that.

jayvdb removed Xqt as the assignee of this task.Feb 10 2015, 1:47 AM
jayvdb set Security to None.
Qgil triaged this task as Lowest priority.Feb 11 2015, 12:56 PM

Wikimedia will apply to Google Summer of Code and Outreachy on Tuesday, February 17. If you want this task to become a featured project idea, please follow these instructions.

@jayvdb, some more information about this would be very welcome!

I run into this (misconfigured?) abuse filter every once in a while:

  File "C:\pywikibot\coredev\pywikibot\page.py", line 4194, in addSources
    data = self.repo.editSource(self, claims, new=True, **kwargs)
  File "C:\pywikibot\coredev\pywikibot\site.py", line 1087, in callee
    return fn(self, *args, **kwargs)
  File "C:\pywikibot\coredev\pywikibot\site.py", line 5882, in editSource
    data = req.submit()
  File "C:\pywikibot\coredev\pywikibot\data\api.py", line 1734, in submit
    raise APIError(**result['error'])
pywikibot.data.api.APIError: failed-save: <abusefilter-warning-63>
<class 'pywikibot.data.api.APIError'>
CRITICAL: Closing network session.

The only action for this filter (https://www.wikidata.org/wiki/Special:AbuseFilter/63) is to warn. The bot shouldn't throw an api error, the bot should may show a warning and retry.

It should be possible to request whether the abusefilter is a warning (unless abusefilter actually check queries ;) ): https://www.wikidata.org/w/api.php?action=query&list=abusefilters&abfstartid=63&abflimit=1 And then it could retry it. The question is how to detect it (aka what's are its unique properties in the error message) so that we can just retry it.

We could setup some test cases on one of the test wiki, hit it with a bot and see what the api spits out. Come to think of it, these would also be excellent integrated unit tests to setup ;-)

This is a message posted to all tasks under "Re-check in September 2015" at Possible-Tech-Projects. Outreachy-Round-11 is around the corner. If you want to propose this task as a featured project idea, we need a clear plan with community support, and two mentors willing to support it.

This is a message sent to all Possible-Tech-Projects. The new round of Wikimedia Individual Engagement Grants is open until 29 Sep. For the first time, technical projects are within scope, thanks to the feedback received at Wikimania 2015, before, and after (T105414). If someone is interested in obtaining funds to push this task, this might be a good way.

I see that a patch has been already merged for this by @Xqt and that some small issues remain.
As this is now too small a task for GSoC/Outreachy, I'm removing the Possible-Tech-Projects project.

I see that a patch has been already merged for this by @Xqt and that some small issues remain.
As this is now too small a task for GSoC/Outreachy, I'm removing the Possible-Tech-Projects project.

No, that is an unrelated patch. See T85656#1011072 .

jayvdb renamed this task from detect and correctly handle edits that trigger abusefilter rules to Pywikibot to detect and correctly handle edits that trigger abusefilter rules.Oct 9 2015, 7:00 AM
jayvdb updated the task description. (Show Details)

@Multichill, @XZise - anyone interested in mentoring this project for the upcoming Outreachy round?

This is the last call for Possible-Tech-Projects missing mentors. The application deadline for Outreachy-Round-11 is 2015-11-02. If this proposal doesn't have two mentors assigned by the end of Thursday, October 22, it will be moved as a candidate for the next round.

Interested in mentoring? Check the documentation for possible mentors.

As previously mentioned, this task is moved to 'Recheck in February 2016' as it doesn't have two mentors assigned to it as of today, October 23 - 2015. The project will be included in the discussion of next iteration of GSoC/Outreachy, and is excluded from #Outreachy-11. Potential candidates are discouraged from submitting proposals to this task for #Outreachy-11 as it lacks mentors in this round.

NOTE: This task is a proposed project for Google-Summer-of-Code (2016) and Outreachy-Round-12 : GSoC 2016 and Outreachy round 12 is around the corner, and this task is listed as a Possible-Tech-Projects for the same. Projects listed for the internship programs should have a well-defined scope within the timeline of the event, minimum of two mentors, and should take about 2 weeks for a senior developer to complete. Interested in mentoring? Please add your details to the task description, if not done yet. Prospective interns should go through Life of a successful project doc to find out how to come up with a strong proposal for the same.
jayvdb raised the priority of this task from Lowest to Medium.Mar 7 2016, 4:08 AM

There are a few abusefilter related problems in pywikibot, so this project would be quite valuable to flesh them out and fix them.

There are a few abusefilter related problems in pywikibot, so this project would be quite valuable to flesh them out and fix them.

As soon as this task gets a co-mentor, we can have it featured for this round of GSoC/Outreachy. Scope and microtasks are well-defined.

@jayvdb can we have this one for the current Outreachy round?

Hi I'm a final year undergrad at Indian Institute of Technology Mandi, India. I'm interested in working on this project as a part of Outreachy-13, I'm done with gerrit and vagrant set up and familiarising myself with the platform right now. Should I go ahead with the microtask T103284 or is there something else that I can start before that to enhance my grip on the platform, code base and project itself?

Hi I'm a final year undergrad at Indian Institute of Technology Mandi, India. I'm interested in working on this project as a part of Outreachy-13, I'm done with gerrit and vagrant set up and familiarising myself with the platform right now. Should I go ahead with the microtask T103284 or is there something else that I can start before that to enhance my grip on the platform, code base and project itself?

You should familiarize yourself with pywikibot and try to fix some easy pywikibot bugs from https://phabricator.wikimedia.org/maniphest/query/zkPELsbclbQr/#R

If you're confident about the microtask, most welcome to attempt it.

Is this project still missing a mentor?
Is there a common place you all meet periodically? I am interested in mentoring, and would love to introduce myself on the mail-list/IRC.

Is this project still missing a mentor?
Is there a common place you all meet periodically? I am interested in mentoring, and would love to introduce myself on the mail-list/IRC.

@Shubhpatel108 thanks for your interest, the project needs a co-mentor but in order to be a mentor, one needs to have prior experience with contributing to MediaWiki or related experience.

You can introduce yourself on Wikitech-l or MediaWiki-General irc channel. I again state that mentorship requires a decent knowledge of the MediaWiki architecture and previous experience and/or contributions.

Hi all!
I am new and hence unsure about how to start contributing for Outreachy, Could anyone please tell me more about this project?
Thanks :)
Zoya

A good way to start is to set up a MediaWiki installation on your computer, with the abuse filter extension, set up some abuse filter rules on your own wiki, using various abuse rule options, and then

  1. trigger them manually with a normal browser
  2. trigger them automatically with a MediaWiki client, preferably Pywikibot.

Look at https://www.mediawiki.org/wiki/Special:AbuseFilter and https://en.wikipedia.org/wiki/Special:AbuseFilter to see what rules big wikis create, and why, and think about how an automated MediaWiki client should respond when it hits one of those rules.

Hi I'm a final year undergrad at Indian Institute of Technology Mandi, India. I'm interested in working on this project as a part of Outreachy-13, I'm done with gerrit and vagrant set up and familiarising myself with the platform right now. Should I go ahead with the microtask T103284 or is there something else that I can start before that to enhance my grip on the platform, code base and project itself?

Since you mentioned you are a university student, please check out https://wiki.gnome.org/Outreachy#Eligibility to confirm your elgibility, please.

@01tonythomas I have my college vacations from Dec to mid Feb i.e. approximately 10-11 weeks of vacations that coincide with the Outreachy internship period, so I can easily give 40+ hours to it. Other than that I'll be in college only for last 3 weeks during the intern, which I think satisfies the eligibility criteria.

jayvdb updated the task description. (Show Details)

This seems to have stalled. It is currently an issue I am running into as well that is preventing my bot from doing its job on commons. It seems convinced that every file is a gallery when it isn't.

@TheSandDoctor: Do you have a traceback for this issue?

Change 680768 had a related patch set uploaded (by JJMC89; author: JJMC89):

[pywikibot/core@master] [IMPR] Handle abusefilter-{disallow,warning} codes

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

Change 680768 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Handle abusefilter-{disallow,warning} codes

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

JJMC89 removed a project: Patch-For-Review.