Page MenuHomePhabricator

User not logged in when running any script right after login script
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

D:\pywikibot>pwb.py login
WARNING: No user is logged in on site wikisource:gu
Password for user Dsvyas on wikisource:gu (no characters will be shown):
Logging in to wikisource:gu as Dsvyas
Please enter a verification code from your authentication device.:
Logged in on wikisource:gu as Dsvyas.
D:\pywikibot>python pwb.py protect -file:unprotect.txt -unprotect -summary:"Unprotecting for Reverse Transclusion"

What happens?:

Error:
    raise UserRightsError('User "{}" does not have required '
pywikibot.exceptions.UserRightsError: User "None" does not have required user right "protect"
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.UserRightsError'>

What should have happened instead?:

The script runs without error

Software version:

pywikibot 8.0.0

Other information:

Event Timeline

Same for other scripts which use any rights when reading:

D:\pwb\GIT\core>pwb login
Logged in on wikipedia:de as Xqtest.

Execution time: 0 seconds

D:\pwb\GIT\core>pwb watchlist
Retrieving watchlist for wikipedia:de.
WARNING: API error notloggedin: Please log in to view or edit items on your watchlist.
Traceback (most recent call last):
  File "D:\pwb\GIT\core\pwb.py", line 39, in <module>
    sys.exit(main())
             ^^^^^^
  File "D:\pwb\GIT\core\pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 516, in <module>
    main()
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 500, in main
    if not execute():
           ^^^^^^^^^
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 487, in execute
    run_python_file(filename, script_args, module)
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "D:\pwb\GIT\core\scripts\watchlist.py", line 158, in <module>
    main()
  File "D:\pwb\GIT\core\scripts\watchlist.py", line 147, in main
    count_watchlist(site)
  File "D:\pwb\GIT\core\scripts\watchlist.py", line 53, in count_watchlist
    watchlist_count = len(refresh(site))
                          ^^^^^^^^^^^^^
  File "D:\pwb\GIT\core\scripts\watchlist.py", line 82, in refresh
    return list(site.watched_pages(force=True))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen _collections_abc>", line 330, in __next__
  File "D:\pwb\GIT\core\pywikibot\tools\collections.py", line 275, in send
    return next(self._started_gen)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pwb\GIT\core\pywikibot\data\api\_generators.py", line 610, in generator
    self.data = self.request.submit()
                ^^^^^^^^^^^^^^^^^^^^^
  File "D:\pwb\GIT\core\pywikibot\data\api\_requests.py", line 1083, in submit
    raise pywikibot.exceptions.APIError(**error)
pywikibot.exceptions.APIError: notloggedin: Please log in to view or edit items on your watchlist.
[servedby: mw2354;
 help: See https://de.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes.]
CRITICAL: Exiting due to uncaught exception APIError: notloggedin: Please log in to view or edit items on your watchlist.
[servedby: mw2354;
 help: See https://de.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes.]

D:\pwb\GIT\core>

This was introduced with rPWBCba56084

Xqt renamed this task from User not logged in when running protect script right after login script to User not logged in when running any script right after login script.Apr 6 2023, 7:27 AM
Xqt triaged this task as High priority.
Xqt changed the task status from Open to In Progress.Apr 6 2023, 7:59 AM
Xqt claimed this task.

Change 906547 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] No longer lazy load cookies

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

Change 906547 merged by Xqt:

[pywikibot/core@master] [bugfix] No longer lazy load cookies

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

Change 908207 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@stable] [bugfix] No longer lazy load cookies

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

Change 908207 merged by Xqt:

[pywikibot/core@stable] [bugfix] No longer lazy load cookies

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

Has this been fixed? I am still getting the same issue while trying to protect/unprotect. Have downloaded most recent commit for Core to make sure I was using the updated protect.py file.