Page MenuHomePhabricator

OAuth: don't abort if the username does not exist on project
Open, MediumPublicBUG REPORT

Description

When removing Category:Wp/olo on olo.wikipedia.org (a relict left from importing the site from incubator), the bot systematically fails and abort if the page where the category is to be removed has an interwiki link (old-style, not wikidata) and the bot account is not registered on that site. I'm not sure if that's the desired behaviour.

WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
ERROR: Fatal error:
Traceback (most recent call last):
  File ".\scripts\category.py", line 1282, in main
    bot.run()
  File ".\scripts\category.py", line 574, in run
    self._change(pagegenerators.CategorizedPageGenerator(self.oldcat))
  File ".\scripts\category.py", line 615, in _change
    sortKey=self.keep_sortkey)
  File "F:\MWDEV\pywikibot-core\pywikibot\page.py", line 2073, in change_category
    newtext = textlib.replaceCategoryLinks(oldtext, cats)
  File "F:\MWDEV\pywikibot-core\pywikibot\textlib.py", line 1246, in replaceCategoryLinks
    interwiki = getLanguageLinks(s2, insite=site)
  File "F:\MWDEV\pywikibot-core\pywikibot\tools\__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "F:\MWDEV\pywikibot-core\pywikibot\textlib.py", line 856, in getLanguageLinks
    result[site] = pywikibot.Page(site, pagetitle)
  File "F:\MWDEV\pywikibot-core\pywikibot\tools\__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "F:\MWDEV\pywikibot-core\pywikibot\tools\__init__.py", line 1447, in wrapper
    return obj(*__args, **__kw)
  File "F:\MWDEV\pywikibot-core\pywikibot\page.py", line 2178, in __init__
    super(Page, self).__init__(source, title, ns)
  File "F:\MWDEV\pywikibot-core\pywikibot\page.py", line 160, in __init__
    self._link = Link(title, source=source, defaultNamespace=ns)
  File "F:\MWDEV\pywikibot-core\pywikibot\page.py", line 4939, in __init__
    self._defaultns = self._source.namespaces[defaultNamespace]
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 1014, in namespaces
    self._namespaces = NamespacesDict(self._build_namespaces())
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 2610, in _build_namespaces
    is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 2717, in version
    version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 1676, in get
    preloaded = self._get_general(key, expiry)
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 1622, in _get_general
    default_info = self._get_siteinfo(props, expiry)
  File "F:\MWDEV\pywikibot-core\pywikibot\site.py", line 1548, in _get_siteinfo
    data = request.submit()
  File "F:\MWDEV\pywikibot-core\pywikibot\data\api.py", line 2342, in submit
    self._data = super(CachedRequest, self).submit()
  File "F:\MWDEV\pywikibot-core\pywikibot\data\api.py", line 2175, in submit
    % (self.site, info))
pywikibot.exceptions.NoUsername: Failed OAuth authentication for wikipedia:hif: The authorization headers in your request are for a user that does not exist here
F:\MWDEV\pywikibot-core>

Thank you.

Event Timeline

@Ladsgroup Maybe your "Dexbot" could be run on olowiki so old interwiki links are added/migrated to Wikidata, while we await resolution on this one? (olowiki is now part of the global bot policy so Dexbot edits won't be a problem there). Thanks!

I suppose that this problem does not concern only category.py, I've the same with one of my own script that work on translations, that do API requests of Wikipedias on various languages.

Framawiki renamed this task from category.py with OAuth: don't abort if the username does not exist on other project to OAuth: don't abort if the username does not exist on project.Apr 17 2017, 5:47 PM
Framawiki edited projects, added Pywikibot-OAuth; removed Pywikibot-category.py.
Xqt triaged this task as Medium priority.Jul 31 2019, 7:27 PM
Xqt changed the subtype of this task from "Task" to "Bug Report".

Change 528085 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/core@master] Allow basic grant holders to autocreate accounts

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

Change 528085 merged by jenkins-bot:
[mediawiki/core@master] Allow basic grant holders to autocreate accounts

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