Page MenuHomePhabricator

AbuseFilter should provide error/warning messages in an API-friendly plaintext format
Open, Needs TriagePublic

Description

AbuseFilter prevents edits via a hook and makes that hook return messages which are huge HTML blobs, typically including some big warning rectangle with colors and an icon, and some text in the middle. Since it can prevent API edits, and the HTML blob is not really useful for the API (the client might not even be able to display HTML, and even if it does, the big block might not fit with the design or the device constraints), it should be possible to get the message in a more flexible format.

This is not trivial as the message might contain <p> tags (a corresponding text message would probably have multiple paragraphs), hyperlinks (easy to turn to plaintext, but useful for some clients which would still not want the formatting), inline styling, lists etc. (Here is an example of a more involved filter message). Also the warning boilerplates tend to have information which doesn't really fit in an error message but can be useful (like where to report filter errors on the given wiki). Also any new syntax should support gradual migration or backwards compatibility as the HTML wrappers are part of the community-defined message, so those messages themselves would have to be changed.

Some options:

  • Provide an URL to the wiki page with the warning notice, as an alternative to returning the contents of the notice. (This would require some kind of structured output from the hook beyond just a message, which seems like a good idea in general.)
  • Allow defining a plantext version of the warning inside the same message in some kind of invisible, easy-to-parse-out syntax (wikitext comment? hidden div like it's done for CommonsMetadata? parser function? maybe even MCR?) and update the existing warning messages with such alternatives.
  • (probably in concert with the previous option) allow returning a (short) main error message and a help message which explains it in more details (as many AbuseFilter templates do this, at length).

Event Timeline

[Thought bubble too, not sure of whether it can be included or not.]

Currently global abuse filters only produce a single non-editable message. Often understandable, though completely restrictive.

Non-editable in what sense? That it cannot be customized on meta or it cannot be customized on the target wiki?

They are the one static message from WMF messages—I am guessing they are translated at translatewiki

Custom warning or disallow messages are not supported for global filters

is the message if you try to amend from "abusefilter-disallowed"

They are the one static message from WMF messages—I am guessing they are translated at translatewiki

Custom warning or disallow messages are not supported for global filters

is the message if you try to amend from "abusefilter-disallowed"

This is unrelated to this task and would deserve its own. Anyway, I believe that this restriction exists because retrieving the message from a foreign wiki can take some time, thus slowing down the edit attempt. I guess this might be resolved by storing the messages in WAN cache, possibly with a long TTL and proper invalidation. We might also warm up this cache during the edit stash phase.