Page MenuHomePhabricator

pywikibot can't login in wikitech with bot password
Closed, DuplicatePublicBUG REPORT

Description

This is only happens if it's pywikibot and bot password and it's wikitech. It logs in but returns an error like this:

ERROR: 172.16.6.30 != Dexbot after APISite.login() and successful ClientLoginManager.login()

Everything else works just fine.

(See T391346)

Event Timeline

Xqt triaged this task as High priority.May 30 2025, 3:16 PM
Xqt changed the subtype of this task from "Task" to "Bug Report".
Xqt moved this task from Backlog to Login on the Pywikibot board.

login module wasn't changed for 16 months,
site.TokenWallet wasn't changed for 2 years,
site.login wasn't changed for 10 months,
affected parts of api.Request weren't changed for 10 months.

What is the current Pywikibot release running? And what was changed upstream within the last 10 months? What are the command to reproduce this issue?

I made sure to update pywikibot and still could reproduce it. Someone else could reproduce it too.

I wasn't able to reproduce it:

>>> import pywikibot
>>> s = pywikibot.Site('wikitech:en')
>>> s.login(user='pywikibot-test')
Password for user Pywikibot-test on wikitech:en (no characters will be shown): Warning: Password input may be echoed.
<redacted botname>@<redacted password>
>>> s.user()
'Pywikibot-test'
>>> s.logged_in()
True

What is your login procedure to reproduce the given issue?

(btw the error message is thrown by this line: https://gerrit.wikimedia.org/g/pywikibot/core/+/d0e896350a14a4f82d7cdd4862775bf8e87abe1d/pywikibot/site/_apisite.py#435 )

I suggest to delete the corresponding cookie-file pywikibot-<Username>.lwp. Does this help?

I deleted that and didn't fix the issue. Also this only happens with bot password not actual passwords.

I deleted that and didn't fix the issue. Also this only happens with bot password not actual passwords.

Very strange. Does login work for other wikis?

Pywikibot-test works with bot password for several wikis (see github action). I'll try a test run on wikitech with that account.

I found a similar issue in T272773 but this wasn't tripped for a long time.

I made this small script derived from yours:

import pywikibot
wikitech = pywikibot.Site('en', 'wikitech')
print('login:', wikitech.login())
sal_page = pywikibot.Page(wikitech, 'Server_Admin_Log')
text = sal_page.text
print('text:', len(text))
print('username:', wikitech.username())
print('user:', wikitech.user())
print('logged in:', wikitech.logged_in())
print('logout:', wikitech.logout())
print('username:', wikitech.username())
print('user:', wikitech.user())
print('logged in:', wikitech.logged_in())

I called it several times and got the following result:

C:\pwb\GIT\core>py -3.13 -m pwb -user:pywikibot-test bpwtest
Password for user Pywikibot-test on wikitech:en (no characters will be shown):
login: None
text: 114
username: Pywikibot-test
user: Pywikibot-test
logged in: True
logout: None
username: Pywikibot-test
user: None
logged in: False

Still no idea what happens on your side. Could you please delete the apicache and try again.

This error is printed after the bot forces a API:Userinfo call and the UI name is an IP the current user is not logged in. The log file(s) would be helpful.

The log file(s) would be helpful.

They weren't, just confirmed the login was successful and then the userinfo check wasn't.

I can't reproduce anymore, though. The same bot password I used in the previous test is working fine now.

I can't reproduce anymore, though. The same bot password I used in the previous test is working fine now.

Looks like the same temporary malfunction as we had in T272773. Any idea how we fan give some hints for future use cases?

I think the relevant information would have been what's written in the .lwp file, I just didn't think to ask or check that.

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

[pywikibot/core@master] IMPR: Add additional informations to Site.login error message

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

Change #1155371 merged by jenkins-bot:

[pywikibot/core@master] IMPR: Add additional informations to Site.login error message

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