Page MenuHomePhabricator

API error response for account creation returns unhelpful messagecode _1_2_3
Closed, DuplicatePublic

Description

When attempting to create a new account via the API, one possible failure mode is that the requested username is too similar to an existing username. I believe this is handled by CentralAuth, as it returns the "centralauth-rename-antispoofconflicts2" error message: https://github.com/wikimedia/mediawiki-extensions-CentralAuth/blob/82bfe2f66cc1c585b7617618c5a804580fb4a280/i18n/en.json#L342

It also returns a messagecode, but rather than a unique and stable reference to the type of error, the code it returns is _1_2_3. (By comparison, other account creation errors have useful message codes like acct_creation_throttle_hit or captcha-createaccount-fail.

Here's an example response I received recently:

{"createaccount":{"status":"FAIL","messagecode":"_1_2_3","message":"The username \"Valdecy Batinga da silva\" is too similar to the following username:<ul><li>Valdecy Batinga da Silva</li></ul>Please choose another username."}}

I would like to be able to handle this situation programmatically via the message code.