Page MenuHomePhabricator

CheckUser tests failing for ApiQueryCheckUserLog and SpecialCheckUserLog: "You don't have permission to check users' IP addresses and other information"
Closed, ResolvedPublic

Description

https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php74-noselenium-docker/141952/console

23:42:59 There were 2 errors:
23:42:59 
23:42:59 1) MediaWiki\CheckUser\Tests\Integration\Api\ApiQueryCheckUserLogTest::testRequiredRights with data set "checkuser-log right only" ('checkuser-log', true)
23:42:59 ApiUsageException: You don't have permission to view the checkuser log.
23:42:59 
23:42:59 /workspace/src/includes/api/ApiUsageException.php:73
23:42:59 /workspace/src/includes/api/ApiBase.php:1530
23:42:59 /workspace/src/includes/api/ApiBase.php:1647
23:42:59 /workspace/src/extensions/CheckUser/src/Api/ApiQueryCheckUserLog.php:46
23:42:59 /workspace/src/includes/api/ApiQuery.php:698
23:42:59 /workspace/src/includes/api/ApiMain.php:1931
23:42:59 /workspace/src/includes/api/ApiMain.php:877
23:42:59 /workspace/src/tests/phpunit/includes/api/ApiTestCase.php:169
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserLogTest.php:57
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserLogTest.php:90
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserLogTest.php:116
23:42:59 /workspace/src/tests/phpunit/includes/api/ApiTestCase.php:322
23:42:59 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
Logs generated by test

Show Details
23:42:59 
23:42:59 2) MediaWiki\CheckUser\Tests\Integration\Api\ApiQueryCheckUserTest::testRequiredRights with data set "checkuser right only" ('checkuser-right', true)
23:42:59 ApiUsageException: You don't have permission to check users' IP addresses and other information.
23:42:59 
23:42:59 /workspace/src/includes/api/ApiUsageException.php:73
23:42:59 /workspace/src/includes/api/ApiBase.php:1530
23:42:59 /workspace/src/includes/api/ApiBase.php:1647
23:42:59 /workspace/src/extensions/CheckUser/src/Api/ApiQueryCheckUser.php:71
23:42:59 /workspace/src/includes/api/ApiQuery.php:698
23:42:59 /workspace/src/includes/api/ApiMain.php:1931
23:42:59 /workspace/src/includes/api/ApiMain.php:877
23:42:59 /workspace/src/tests/phpunit/includes/api/ApiTestCase.php:169
23:42:59 /workspace/src/tests/phpunit/includes/api/ApiTestCase.php:209
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserTest.php:72
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserTest.php:76
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserTest.php:145
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/Api/ApiQueryCheckUserTest.php:171
23:42:59 /workspace/src/tests/phpunit/includes/api/ApiTestCase.php:322
23:42:59 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
Logs generated by test

Show Details
23:42:59 
23:42:59 --
23:42:59 
23:42:59 There was 1 failure:
23:42:59 
23:42:59 1) MediaWiki\CheckUser\Tests\Integration\CheckUser\SpecialCheckUserLogTest::testRequiredRights with data set "checkuser-log right only" ('checkuser-log', true)
23:42:59 Groups/rights given to the test user should allow it to access the CheckUserLog.
23:42:59 Failed asserting that an array contains 'checkuser-log'.
23:42:59 
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/CheckUser/SpecialCheckUserLogTest.php:74
23:42:59 /workspace/src/extensions/CheckUser/tests/phpunit/integration/CheckUser/SpecialCheckUserLogTest.php:106
23:42:59 phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97
Logs generated by test

Show Details
23:42:59 
23:42:59 ERRORS!
23:42:59 Tests: 5127, Assertions: 29182, Errors: 2, Failures: 1, Skipped: 99.

Event Timeline

I'm not too familiar with CheckUser, but if this is a real bug and not a test issue, then it would probably be significantly disruptive.

Unable to reproduce the test failures on my local wiki. Is reproducable on a DNM build test for CheckUser at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/963406.

The failing tests redefines the wgGroupPermissions config to define a new user group. This (from what I can tell) seems to be the cause of the problem, even if this isn't necessarily completely the fault of the test. Some thoughts on what this could be:

  1. The * user group having rights removed recently from WMF config
  2. Some kind of caching causing the wgGroupPermissions config to not be re-read for the test
  3. The method of overriding the config causes problems because other user groups do not exist (the test should instead extend the wgGroupPermissions config)

FWIW, I was able to set up CheckUser locally, and I also can't reproduce the failure (and the API and special page are working), which is somewhat reassuring that this is just a test setup problem.

This probably doesn't need to block the deployment then, but it would still be good to resolve it, since it will cause problems when backporting unrelated patches.

Change 982373 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/CheckUser@master] tests: Use MediaWikiIntegrationTestCase::setGroupPermissions

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

Could be a fail-out from 881c39ac3f4d3adf39ab363c1fe37e97d67807aa when looking at the timeline. The config given to overrideMwServices is ignored when there are calls to setMwGlobals or overrideConfigValue for the same value and now the reset of services is not done in some situation in CI, but possible locally.
I am not 100% sure about that, but uploaded a fix to use a proper function from the test class that passed.

Could be a fail-out from 881c39ac3f4d3adf39ab363c1fe37e97d67807aa when looking at the timeline. The config given to overrideMwServices is ignored when there are calls to setMwGlobals or overrideConfigValue for the same value and now the reset of services is not done in some situation in CI, but possible locally.
I am not 100% sure about that, but uploaded a fix to use a proper function from the test class that passed.

Thanks for the fix. I've +2'd it.

Change 982373 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] tests: Use MediaWikiIntegrationTestCase::setGroupPermissions

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

CI is now working on the Flow extension and CheckUser extension, so I think this can be resolved.

Change 982835 had a related patch set uploaded (by Subramanya Sastry; author: Umherirrender):

[mediawiki/extensions/CheckUser@wmf/1.42.0-wmf.9] tests: Use MediaWikiIntegrationTestCase::setGroupPermissions

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

Change 982835 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@wmf/1.42.0-wmf.9] tests: Use MediaWikiIntegrationTestCase::setGroupPermissions

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

Mentioned in SAL (#wikimedia-operations) [2023-12-13T22:35:12Z] <jhuneidi@deploy2002> Started scap: Backport for [[gerrit:982835|tests: Use MediaWikiIntegrationTestCase::setGroupPermissions (T353210)]], [[gerrit:982834|Temporarily disable isPreview in Parsoid's rendering]]

Mentioned in SAL (#wikimedia-operations) [2023-12-13T22:37:17Z] <jhuneidi@deploy2002> ssastry and jhuneidi: Backport for [[gerrit:982835|tests: Use MediaWikiIntegrationTestCase::setGroupPermissions (T353210)]], [[gerrit:982834|Temporarily disable isPreview in Parsoid's rendering]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-12-13T22:45:22Z] <jhuneidi@deploy2002> Finished scap: Backport for [[gerrit:982835|tests: Use MediaWikiIntegrationTestCase::setGroupPermissions (T353210)]], [[gerrit:982834|Temporarily disable isPreview in Parsoid's rendering]] (duration: 10m 08s)