Page MenuHomePhabricator

Abuse filters with array index access cannot be saved anymore: "MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException: notarray"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue (include links if applicable):

  1. Go to Special:AbuseFilter/new
  2. Set the following conditions: added_lines[0] & false
  3. Save the filter

It also happens when updating an existing filter with similar conditions.

What happens?:

You get an error like:

[6f778b4a-04a4-403e-9a9e-894fe8258f81] 2024-06-22 19:43:24: Kritická výjimka typu „MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException“
resp.
MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException: notarray

What should have happened instead?:

The filter is saved. Or the exception is handled, and the error is more user-friendly.

Other information (browser name/version, screenshots, etc.):

Probably caused by rEABFf5d7b6890898c2e4c672142de70a91ba3ec0f099.

This can become annoying when you really really need to update a filter but are not allowed to do so.

Event Timeline

Having reproduced locally, I found it is this exception. The type is null (no variable has a value). Maybe it should handle DNULL in the same way as DUNDEFINED?

This seems to affect any filter with an error in the "path not taken": This

old_size > 0 & new_size / old_size < 0.5

gives me

[3e374600-82e9-4f10-8656-9983c4facaf7] 2024-06-23 20:41:55: Fatal exception of type "MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException"

Brainstorming here, but if all we're interested in is the names of any variables that might be used, is it really necessary to evaluate the filter? Maybe just extract the names from AbuseFilterTokenizer's output instead?

Change #1049092 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/AbuseFilter@master] [POC] getReferencedVars

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

Brainstorming here, but if all we're interested in is the names of any variables that might be used, is it really necessary to evaluate the filter? Maybe just extract the names from AbuseFilterTokenizer's output instead?

I made a proof of concept, but it isn't finished. Everyone is free to amend the patch (or make an alternative).

Change #1052272 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/AbuseFilter@master] Simplify FilterEvaluator::getUsedVars using ::checkSyntax

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

Change #1052272 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Simplify FilterEvaluator::getUsedVars using ::checkSyntax

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

Aklapper renamed this task from Abuse filters with array index access cannot be saved anymore to Abuse filters with array index access cannot be saved anymore: "MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleException: notarray".Jul 11 2024, 10:57 AM
Aklapper changed the subtype of this task from "Bug Report" to "Production Error".
Aklapper updated the task description. (Show Details)

Change #1049092 abandoned by STran:

[mediawiki/extensions/AbuseFilter@master] Introduce and use FilterEvaluator::getReferencedVars

Reason:

Resolved by I637367c3b3850f7988d890379fef7f4753159953

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