Page MenuHomePhabricator

UserRightsError: User does not have required user right "purge"
Closed, ResolvedPublic

Description

The purge user right was removed made implicit in MW 1.42-wmf1 (and backported to MW 1.41). T291316: 'purge' permission is not checked for action=purge

This means a UserRightsError is raised when APISite.purgepages is called.

2023-10-19 20:14:14             bot.py,  475 in     writelogheader: VERBOSE
2023-10-19 20:14:14             bot.py,  476 in     writelogheader: VERBOSE  === Pywikibot framework v8.3.3 -- Logging header ===
2023-10-19 20:14:14             bot.py,  480 in     writelogheader: VERBOSE  COMMAND: ['/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/multi/purge.py', '--forcelinkupdate', '-ns:0', '-cat:Pages with script errors']
2023-10-19 20:14:14             bot.py,  483 in     writelogheader: VERBOSE  DATE: 2023-10-19 20:14:14.257188 UTC
2023-10-19 20:14:14             bot.py,  487 in     writelogheader: VERBOSE  VERSION: pywikibot/__init__.py (, -1 (unknown), 2023/10/02, 23:59:43, n/a)
2023-10-19 20:14:14             bot.py,  494 in     writelogheader: VERBOSE  SYSTEM: posix.uname_result(sysname='Linux', nodename='purge-script-errors-ns0-28295764-dndfq', release='4.19.0-25-cloud-amd64', version='#1 SMP Debian 4.19.289-2 (2023-08-08)', machine='x86_64')

[...]

2023-10-19 20:14:14             bot.py,  538 in     writelogheader: VERBOSE  =========================================================
2023-10-19 20:14:14        throttle.py,  181 in  checkMultiplicity: VERBOSE  Found 2 wikipedia:en processes running, including this one.
2023-10-19 20:14:15             bot.py, 1387 in       current_page: STDOUT   Working on 'Comparison of web browsers'
2023-10-19 20:14:15        __init__.py,  384 in             _flush: VERBOSE  Dropped throttle(s).
2023-10-19 20:14:15             bot.py, 1532 in               exit: INFO
2023-10-19 20:14:15             bot.py, 1534 in               exit: INFO     1 read operation
2023-10-19 20:14:15             bot.py, 1544 in               exit: INFO     Execution time: 0 seconds
2023-10-19 20:14:15             bot.py, 1548 in               exit: INFO     Read operation time: 0.0 seconds
2023-10-19 20:14:15             bot.py, 1559 in               exit: INFO     Script terminated
2023-10-19 20:14:15             bot.py, 1563 in               exit: INFO     by exception:
2023-10-19 20:14:15         logging.py,  335 in          exception: ERROR    User "JJMC89 bot" does not have required user right "purge" (UserRightsError)
2023-10-19 20:14:15            http.py,  119 in              flush: VERBOSE  Closing network session.
2023-10-19 20:14:15            http.py,  123 in              flush: VERBOSE  Traceback (most recent call last):
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/multi/purge.py", line 86, in <module>
    raise SystemExit(main())
                     ^^^^^^
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/multi/purge.py", line 81, in main
    PurgeBot(generator=gen, **vars(parsed_args)).run()
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.11/site-packages/pywikibot/bot.py", line 1671, in run
    self.treat(page)
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.11/site-packages/pywikibot/bot.py", line 1924, in treat
    self.treat_page()
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/multi/purge.py", line 24, in treat_page
    if self.current_page.purge(**self.opt):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.11/site-packages/pywikibot/page/_basepage.py", line 1403, in purge
    return self.site.purgepages([self], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.11/site-packages/pywikibot/site/_decorators.py", line 89, in callee
    raise UserRightsError('User "{}" does not have required '
pywikibot.exceptions.UserRightsError: User "JJMC89 bot" does not have required user right "purge"
2023-10-19 20:14:15            http.py,  132 in              flush: CRITICAL Exiting due to uncaught exception UserRightsError: User "JJMC89 bot" does not have required user right "purge"
2023-10-19 20:14:15            http.py,  137 in              flush: VERBOSE  Network session closed.

Event Timeline

Change 967304 had a related patch set uploaded (by JJMC89; author: JJMC89):

[pywikibot/core@master] remove check for purge right from APISite.purgepages

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

I'm a bit confused about the description of the issue. Making the purge right implcite should not cause permission errors. To the contrary, it should make sure that the permission is always granted.

Note that previously, the right was not "implicite", it was simply not checked at all. With the new code, rate limits apply to it.

Making the purge right implcite should not cause permission errors. To the contrary, it should make sure that the permission is always granted.

Special:ListGroupRights no longer had purge for any group, and the API does not have it included in the list of a user's rights.

Pywikibot checks the if the user has the purge right before making a POST to the purge API.

Making the purge right implcite should not cause permission errors. To the contrary, it should make sure that the permission is always granted.

Special:ListGroupRights no longer had purge for any group, and the API does not have it included in the list of a user's rights.

Pywikibot checks the if the user has the purge right before making a POST to the purge API.

Ah, I see. Thank you for the explanation.

Change 967304 merged by jenkins-bot:

[pywikibot/core@master] remove check for purge right from APISite.purgepages

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