Page MenuHomePhabricator

login: Unable to switch users when using BotPasswords
Open, Needs TriagePublicBUG REPORT

Description

I run scripts with 2 accounts: bot and admin bot
Both accounts have botpasswords defined

$ python3 pwb.py login
Logged in on wikipedia:pl as MastiBot.admin.
(venv) [mst@mort core]$ python3 pwb.py login -user:mastiBot
Logging in to wikipedia:pl as MastiBot@mastiBot
Traceback (most recent call last):
  File "/home/mst/pw3/core/pywikibot/data/api.py", line 2990, in login_to_site
    response['messagecode'] == 'login-throttled'
KeyError: 'messagecode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pwb.py", line 363, in <module>
    if not main():
  File "pwb.py", line 358, in main
    file_package)
  File "pwb.py", line 75, in run_python_file
    main_mod.__dict__)
  File "./scripts/login.py", line 151, in <module>
    main()
  File "./scripts/login.py", line 139, in main
    site.login(autocreate=autocreate)
  File "/home/mst/pw3/core/pywikibot/tools/__init__.py", line 1478, in wrapper
    return obj(*__args, **__kw)
  File "/home/mst/pw3/core/pywikibot/site/_apisite.py", line 404, in login
    if login_manager.login(retry=True, autocreate=autocreate):
  File "/home/mst/pw3/core/pywikibot/login.py", line 312, in login
    self.login_to_site()
  File "/home/mst/pw3/core/pywikibot/data/api.py", line 2998, in login_to_site
    'handled:\n{}'.format(response))
pywikibot.exceptions.CaptchaError: Captcha encountered which cannot be handled:
{'result': 'Aborted', 'reason': 'Cannot log in when using MediaWiki\\Session\\BotPasswordSessionProvider sessions.'}
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.CaptchaError'>
$ python --version
Python 3.6.8
$ python3 pwb.py version
Pywikibot: [git@github.com:masti0]  (93ca9c1, g14433, 2021/03/16, 15:48:38, OUTDATED)
Release version: 6.1.0.dev0
requests version: 2.25.1
  cacerts: /home/mst/pw3/core/venv/lib64/python3.6/site-packages/certifi/cacert.pem
    certificate test: ok
Python: 3.6.8 (default, Aug 13 2020, 07:46:32) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: 
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /home/mst/pw3/core
Usernames for family "wikipedia":
	*: MastiBot.admin

on other machine "main" user is mastiBot and situation is exactly same but with reversed users

Event Timeline

Reedy renamed this task from unable to login du to CAPTCHA while swithching users to unable to login du to CAPTCHA while switching users.Mar 16 2021, 10:10 PM
Masti renamed this task from unable to login du to CAPTCHA while switching users to unable to login due to CAPTCHA while switching users.Mar 16 2021, 10:11 PM

Those bots are autoconfirmed. .admin bot has even an admin flag

JJMC89 renamed this task from unable to login due to CAPTCHA while switching users to login: Unable to switch users when using BotPasswords.Mar 16 2021, 11:33 PM
JJMC89 changed the subtype of this task from "Task" to "Bug Report".Mar 16 2021, 11:45 PM
JJMC89 added a subscriber: JJMC89.

The captcha exception looks to be incorrect. The expected messagecode key is missing in

{'result': 'Aborted', 'reason': 'Cannot log in when using MediaWiki\\Session\\BotPasswordSessionProvider sessions.'}

but that isn't captcha issue.

Was this working as expected before?

As a workaround, you can do python3 pwb.py login -logout before switching users.