Page MenuHomePhabricator

Special:UserRights in interwiki mode: Wikimedia\Assert\PreconditionException: Expected MediaWiki\User\UserIdentityValue to belong to the local wiki, but it belongs to 'metawiki'
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\PreconditionException: Expected MediaWiki\User\UserIdentityValue to belong to the local wiki, but it belongs to 'metawiki'
exception.trace
from /srv/mediawiki/php-1.41.0-wmf.19/includes/dao/WikiAwareEntityTrait.php(59)
#0 /srv/mediawiki/php-1.41.0-wmf.19/includes/user/UserIdentityValue.php(139): MediaWiki\User\UserIdentityValue->assertWiki(boolean)
#1 /srv/mediawiki/php-1.41.0-wmf.19/includes/user/UserFactory.php(188): MediaWiki\User\UserIdentityValue->getId()
#2 /srv/mediawiki/php-1.41.0-wmf.19/includes/ServiceWiring.php(2232): MediaWiki\User\UserFactory->newFromUserIdentity(MediaWiki\User\UserIdentityValue)
#3 /srv/mediawiki/php-1.41.0-wmf.19/includes/user/UserGroupManager.php(872): Wikimedia\Services\ServiceContainer::{closure}(MediaWiki\User\UserIdentityValue)
#4 /srv/mediawiki/php-1.41.0-wmf.19/includes/specials/SpecialUserRights.php(484): MediaWiki\User\UserGroupManager->addUserToGroup(MediaWiki\User\UserIdentityValue, string, string, boolean)
#5 /srv/mediawiki/php-1.41.0-wmf.19/includes/specials/SpecialUserRights.php(399): MediaWiki\Specials\SpecialUserRights->doSaveUserGroups(MediaWiki\User\UserIdentityValue, array, array, string, array, array)
#6 /srv/mediawiki/php-1.41.0-wmf.19/includes/specials/SpecialUserRights.php(269): MediaWiki\Specials\SpecialUserRights->saveUserGroups(string, MediaWiki\User\UserIdentityValue)
#7 /srv/mediawiki/php-1.41.0-wmf.19/includes/specialpage/SpecialPage.php(701): MediaWiki\Specials\SpecialUserRights->execute(NULL)
#8 /srv/mediawiki/php-1.41.0-wmf.19/includes/specialpage/SpecialPageFactory.php(1565): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.41.0-wmf.19/includes/MediaWiki.php(344): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#10 /srv/mediawiki/php-1.41.0-wmf.19/includes/MediaWiki.php(948): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.41.0-wmf.19/includes/MediaWiki.php(597): MediaWiki->main()
#12 /srv/mediawiki/php-1.41.0-wmf.19/index.php(50): MediaWiki->run()
#13 /srv/mediawiki/php-1.41.0-wmf.19/index.php(46): wfIndexMain()
#14 /srv/mediawiki/w/index.php(3): require(string)
#15 {main}
Impact

This prevents changes of user rights on a different wiki via Special:UserRights, which is a part of the Stewards process to deal with abuse or remove PII from Wikimedia sites. Traiging as UBN/train blocker.

Notes

This is similar to (but different from) T342322: Unable to use interwiki Special:UserRights which happened last week.

We apparently need better tests for interwiki Special:Userrights, as this is the second week in a row in which this feature of Special:Userrights caused a train blocker.

Event Timeline

Urbanecm triaged this task as Unbreak Now! priority.Jul 26 2023, 11:32 AM
Urbanecm created this task.

We apparently need better tests for interwiki Special:Userrights, as this is the second week in a row in which this feature of Special:Userrights caused a train blocker.

Interwiki Userrights means CentralAuth, and we intentionally have no testing at all in the gate for that. :-( T321864#8351379

We apparently need better tests for interwiki Special:Userrights, as this is the second week in a row in which this feature of Special:Userrights caused a train blocker.

Interwiki Userrights means CentralAuth [...]

Not necessarily. AFAIK we only need to have two MediaWiki databases provisioned while CI runs our (integration) tests and the following three lines in LocalSettings.php:

$wgGroupPermissions['bureaucrat']['userrights-interwiki'] = true;
$wgLocalDatabases = ['awiki', 'bwiki'];
$wgConf->wikis = $wgLocalDatabases;

This should be sufficient to enable the interwiki functionality of Special:Userrights (this works locally in MediaWiki-Docker, w/o CentralAuth installed). From there, it should be fairly trivial to test it (at least sufficiently enough to avoid "it throws a fatal" kind of errors).

I haven't examined closely how CI works in our setup, but plugging in a database clonning sequence after install.php runs seems fairly trivial. We should probably ensure the second database resets itself in a similar way like the main test database does (which is definitely less trivial), but we shouldn't need to plug CentralAuth in.

Filled T342763 for the testing bit; the focus of this taks should be fixing the breakage.

This error was caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/923706 -- reverting that patch locally fixes the issue. CC @Umherirrender and @Zabe (author/reviewer respectively).

Change 941876 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/core@master] Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights"

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

Change 941877 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/core@wmf/1.41.0-wmf.19] Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights"

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

Change 941877 merged by jenkins-bot:

[mediawiki/core@wmf/1.41.0-wmf.19] Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights"

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

Mentioned in SAL (#wikimedia-operations) [2023-07-26T14:00:51Z] <urbanecm@deploy1002> Started scap: Backport for [[gerrit:941877|Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights" (T255309 T342747)]]

Mentioned in SAL (#wikimedia-operations) [2023-07-26T14:02:29Z] <urbanecm@deploy1002> urbanecm: Backport for [[gerrit:941877|Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights" (T255309 T342747)]] synced to the testservers mwdebug2001.codfw.wmnet, mwdebug1001.eqiad.wmnet, mwdebug2002.codfw.wmnet, mwdebug1002.eqiad.wmnet, and mw-debug kubernetes deployment (accessible via k8s-experimental XWD option)

Mentioned in SAL (#wikimedia-operations) [2023-07-26T14:13:25Z] <urbanecm@deploy1002> Finished scap: Backport for [[gerrit:941877|Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights" (T255309 T342747)]] (duration: 12m 33s)

Should be fixed in production now (for wmf.19, even). We need to get the patch (or a proper fix) merged to master; currently it fails a gate test with a seemingly-unrelated message.

Urbanecm lowered the priority of this task from Unbreak Now! to High.Jul 26 2023, 5:25 PM

We need to get the patch (or a proper fix) merged to master; currently it fails a gate test with a seemingly-unrelated message.

The merge issue is filled as T342775. For now, re-marking this as a .20 blocker and decreasing prio to high, as it doesn't block this train from going ahead as of now (will the next one).

Change 941876 merged by jenkins-bot:

[mediawiki/core@master] Revert "specials: Use cross-wiki aware UserIdentityLookup on Special:UserRights"

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

Urbanecm claimed this task.

Master patch merged => resolving.