Page MenuHomePhabricator

MWException: Default '""' is invalid for preference nickname of user XXX
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   MWException: Default '""' is invalid for preference nickname of user XXX
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.16/includes/preferences/DefaultPreferencesFactory.php(297)
#0 /srv/mediawiki/php-1.37.0-wmf.16/includes/preferences/DefaultPreferencesFactory.php(250): MediaWiki\Preferences\DefaultPreferencesFactory->loadPreferenceValues(User, DerivativeContext, array)
#1 /srv/mediawiki/php-1.37.0-wmf.16/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(115): MediaWiki\Preferences\DefaultPreferencesFactory->getFormDescriptor(User, DerivativeContext)
#2 /srv/mediawiki/php-1.37.0-wmf.16/includes/api/ApiOptions.php(207): GlobalPreferences\GlobalPreferencesFactory->getFormDescriptor(User, DerivativeContext)
#3 /srv/mediawiki/php-1.37.0-wmf.16/includes/api/ApiOptions.php(114): ApiOptions->getPreferences()
#4 /srv/mediawiki/php-1.37.0-wmf.16/includes/api/ApiMain.php(1842): ApiOptions->execute()
#5 /srv/mediawiki/php-1.37.0-wmf.16/includes/api/ApiMain.php(821): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.37.0-wmf.16/includes/api/ApiMain.php(792): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.37.0-wmf.16/api.php(90): ApiMain->execute()
#8 /srv/mediawiki/php-1.37.0-wmf.16/api.php(45): wfApiMain()
#9 /srv/mediawiki/w/api.php(3): require(string)
#10 {main}
Impact

logspam

Notes

happening for one particular user repeatedly for the past few weeks.

Details

Request URL
https://en.wikipedia.org/w/api.php?format=*&formatversion=*&errorformat=*&errorsuselocal=*&action=options

Event Timeline

It seems the preferences code handling has foreseen a scenario where when fancysig is used, a reset causes the empty string value to be used which is then invalid. It tries to handle this scenario in some way to avoid fatals, but maybe that's not working correctly?

Either way, this shoudl not cause an internal server error.

https://gerrit.wikimedia.org/g/mediawiki/core/+/81dd7da45f60ad23bbfe64babd2d9fa4b5e0bce7/includes/preferences/DefaultPreferencesFactory.php#1629

Umherirrender subscribed.

It is called over the api module.

It is possible to get more information about what preference is changed? That are the query parameter change or optionname/optionvalue
Maybe also neccessary to look up the old value for fancysig and nickname.

I have not found a way to trigger the error locally. Maybe ~~~ is in the database or get's set.

This is low-frequency (218 hits in the last 30 days for a particular user) but persistent.

The scenario here is that the user's current nickname preference is invalid for some reason, so the code fetching their current preferences tries to replace it with the default value, but the default value is also invalid (because it conflicts with their non-default preference for fancysig).

The real issue is the fact that changing one preference can cause another preference to become invalid. They should be somehow defined differently so that this can't happen. But we probably can't do that without some annoying data migration.

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

[mediawiki/core@master] Fix exception in preferences when `nickname` is invalid and `fancysig` is on

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

Change 715254 merged by jenkins-bot:

[mediawiki/core@master] Fix exception in preferences when `nickname` is invalid and `fancysig` is on

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

Jdforrester-WMF assigned this task to matmarex.
Jdforrester-WMF subscribed.

Should be fixed in wmf.21.

Does the fix also apply to an error like the following:

Default 'null' is invalid for preference incubatortestwiki-code of user <username>

?

No, it only affects the 'nickname' preference.

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

[mediawiki/core@REL1_35] Fix exception in preferences when `nickname` is invalid and `fancysig` is on

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

Change 834671 abandoned by Reedy:

[mediawiki/core@REL1_35] Fix exception in preferences when `nickname` is invalid and `fancysig` is on

Reason:

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