Page MenuHomePhabricator

API error response for list=user&usprops=cancreate with similar username has '$1' instead of real error code.
Closed, ResolvedPublicBUG REPORT

Description

Problem

Instead of an error code and error message, the response for a too-similar username says $1.

https://meta.wikimedia.org/w/api.php?action=query&list=users&ususers=Rages0ss&usprop=cancreate

 {
    "batchcomplete": "",
    "query": {
        "users": [
            {
                "name": "Rages0ss",
                "missing": "",
                "cancreateerror": [
                    {
                        "message": "$1",
                        "params": [
                            "The username &quot;Rages0ss&quot; is too similar to the following username:<ul><li>Ragesoss</li></ul>Please choose another username."
                        ],
                        "code": "$1",
                        "type": "error"
                    }
                ]
            }
        ]
    }
}

Acceptance criteria

  • The API response should deliver a proper error message and error code.

Event Timeline

Anomie subscribed.

Not an API error, that's what the underlying code is returning. In this case it seems to be coming from CentralAuth's AntiSpoof code, but AntiSpoof itself does the same thing.

A quick fix would be to use ApiRawMessage in those two places to set a code instead of allowing it to be derived from the message key. The message would still be "$1" though, because that's what the message in fact is. A more thorough fix would be to change the code to use a single message instead of pasting messages together like that.

TBolliger set the point value for this task to 2.Sep 26 2017, 6:17 PM
TBolliger removed the point value for this task.

Currently, it returns a slightly different response... now the code for the error is _1 instead of $1. It should probably be toosimilar instead.

Aklapper changed the subtype of this task from "Task" to "Bug Report".

Change 965753 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/AntiSpoof@master] Use normal localisation message for username conflict error

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

Change 965754 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/CentralAuth@master] Use normal localisation message for username conflict error

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

Change 965753 merged by jenkins-bot:

[mediawiki/extensions/AntiSpoof@master] Use normal localisation message for username conflict error

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

Change 965754 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Use normal localisation message for username conflict error

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

Let no one say that MediaWiki developers aren't responsive to bug reports, you just have to report it 3 times over 5 years and someone will fix it very soon ;)