Page MenuHomePhabricator

CentralAuthIdLookup throws from CentralAuthUser for username with a colon
Open, Needs TriagePublicPRODUCTION ERROR

Description

Similar to T358149 and T375212, I got this error while running the userOptions.php script in hewiki.

sgimeno@mwmaint2002:~$ mwscript userOptions.php --wiki hewiki --usage growthexperiments-homepage-variant
DEPRECATION WARNING: Maintenance scripts are moving to Kubernetes. See
https://wikitech.wikimedia.org/wiki/Maintenance_scripts for the new process.
Maintenance hosts will be going away; please submit feedback promptly if
maintenance scripts on Kubernetes don't work for you. (T341553)
InvalidArgumentException from line 255 of /srv/mediawiki/php-1.43.0-wmf.27/extensions/CentralAuth/includes/User/CentralAuthUser.php: Invalid username: XXX:XXX
#0 /srv/mediawiki/php-1.43.0-wmf.27/extensions/CentralAuth/includes/User/CentralAuthUser.php(230): MediaWiki\Extension\CentralAuth\User\CentralAuthUser::getInstanceByName('XXX:XXX')
#1 /srv/mediawiki/php-1.43.0-wmf.27/extensions/CentralAuth/includes/User/CentralAuthIdLookup.php(114): MediaWiki\Extension\CentralAuth\User\CentralAuthUser::getInstance(Object(MediaWiki\User\User))
#2 /srv/mediawiki/php-1.43.0-wmf.27/extensions/GlobalPreferences/includes/GlobalUserOptionsStore.php(75): MediaWiki\Extension\CentralAuth\User\CentralAuthIdLookup->isOwned(Object(MediaWiki\User\User))
#3 /srv/mediawiki/php-1.43.0-wmf.27/extensions/GlobalPreferences/includes/GlobalUserOptionsStore.php(35): GlobalPreferences\GlobalUserOptionsStore->getStorage(Object(MediaWiki\User\User))
#4 /srv/mediawiki/php-1.43.0-wmf.27/includes/user/Options/UserOptionsManager.php(494): GlobalPreferences\GlobalUserOptionsStore->fetch(Object(MediaWiki\User\User), 0)
#5 /srv/mediawiki/php-1.43.0-wmf.27/includes/user/Options/UserOptionsManager.php(570): MediaWiki\User\Options\UserOptionsManager->loadOptionsFromStore(Object(MediaWiki\User\User), 0)
#6 /srv/mediawiki/php-1.43.0-wmf.27/includes/user/Options/UserOptionsManager.php(460): MediaWiki\User\Options\UserOptionsManager->loadOriginalOptions(Object(MediaWiki\User\User), 0)
#7 /srv/mediawiki/php-1.43.0-wmf.27/includes/user/Options/UserOptionsManager.php(169): MediaWiki\User\Options\UserOptionsManager->loadUserOptions(Object(MediaWiki\User\User), 0)
#8 /srv/mediawiki/php-1.43.0-wmf.27/maintenance/userOptions.php(133): MediaWiki\User\Options\UserOptionsManager->getOption(Object(MediaWiki\User\User), 'growthexperimen...')
#9 /srv/mediawiki/php-1.43.0-wmf.27/maintenance/userOptions.php(75): UserOptionsMaintenance->showUsageStats()
#10 /srv/mediawiki/php-1.43.0-wmf.27/maintenance/includes/MaintenanceRunner.php(703): UserOptionsMaintenance->execute()
#11 /srv/mediawiki/php-1.43.0-wmf.27/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#12 /srv/mediawiki/multiversion/MWScript.php(158): require_once('/srv/mediawiki/...')
#13 {main}

Note: Not sure if this is needs to be tagged as a production error since it happened running script on-demand.

Event Timeline

Same issue as T372880: User::isAllowed throws from CentralAuthUser when username contains colon, with a different entry point.

It would be nice to make these usernames pass RIGOR_VALID somehow, but then a username which is not a valid title would probably break something somewhere.

I noticed a couple more of these, various usernames, all without colons:

(shared as logstash links here to not bring up IPs(?) and other usernames in a public task)

Also, would it be possible to change this exception:

CentralAuthUser.php
		if ( $canonUsername === false || $canonUsername === null ) {
			throw new InvalidArgumentException( "Invalid username: $username" );
		}

to a NormalizedException? Because currently, all these exceptions have the username right in the message and so the rows show up individually in logstash.

Also, would it be possible to change this exception: (...) to a NormalizedException?

This was done at some point. In the ~40 days since, we had 7 instances of this error, all of them with a colon (at a glance, either an interwiki prefix or a namespace alias).

Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptFeb 19 2025, 12:43 PM
Krinkle renamed this task from InvalidArgumentException: Invalid username: <username_with_colon> to CentralAuthIdLookup throws from CentralAuthUser for username with a colon.Dec 16 2025, 7:48 PM