Page MenuHomePhabricator

cosmetic_changes.py: Exiting due to uncaught exception InvalidTitleError: The (non-)talk page of 'مداكرة:قيسارية:طب' is a valid title in another namespace
Open, Needs TriagePublicBUG REPORT

Description

Background information

So, the link title can be translated as:

  • مداكرة:قيسارية:طب --> Talk:Portal:طب

Steps to replicate the issue

python pwb.py cosmetic_changes -start:Talk:! -lang:ary

Output:

Script terminated by exception:

ERROR: The (non-)talk page of 'مداكرة:قيسارية:طب' is a valid title in another namespace. (InvalidTitleError)
Traceback (most recent call last):
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 39, in <module>
    sys.exit(main())
             ^^^^^^
  File "C:\Users\Mohammed\Downloads\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 "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 516, in <module>
    main()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 500, in main
    if not execute():
           ^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 487, in execute
    run_python_file(filename, script_args, module)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "C:\Users\Mohammed\Downloads\core\scripts\cosmetic_changes.py", line 131, in <module>
    main()
  File "C:\Users\Mohammed\Downloads\core\scripts\cosmetic_changes.py", line 127, in main
    bot.run()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1692, in run
    for item in self.generator:
  File "C:\Users\Mohammed\Downloads\core\pywikibot\pagegenerators\__init__.py", line 629, in PreloadingGenerator
    site = page.site
           ^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\_basepage.py", line 141, in site
    return self._link.site
           ^^^^^^^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\_links.py", line 506, in site
    self.parse()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\_links.py", line 450, in parse
    raise InvalidTitleError(
pywikibot.exceptions.InvalidTitleError: The (non-)talk page of 'مداكرة:قيسارية:طب' is a valid title in another namespace.
CRITICAL: Exiting due to uncaught exception InvalidTitleError: The (non-)talk page of 'مداكرة:قيسارية:طب' is a valid title in another namespace.

What happens?:

  • The bot crashes and the bot run has to be restarted again.

What should have happened instead?:

  • The bot should have skipped such pages and continued running on the rest of the namespace.

Software version

Pywikibot: [https] r-pywikibot-core (7300801, g17709, 2023/04/13, 16:11:44, master)
Release version: 8.1.0.dev4
setuptools version: 67.6.1
mwparserfromhell version: 0.6.4
wikitextparser version: n/a
requests version: 2.28.2
    certificate test: ok
Python: 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]

Event Timeline

Can’t this be fixed by adding new namespace aliases (via translatewiki)?

Can’t this be fixed by adding new namespace aliases (via translatewiki)?

Nope. The current page titles are wrong and adding wrong namespace aliases to the ary language file is not needed and will only cause confusion.

The correct solution here would be to run a a maintenance script directly on arywiki to remove all invalid titles from the database. I believe that this task should be run regularly on all wmf wikis, as sometimes, pages with invalid titles get created for various historical bugs in MediaWiki code. This issue is not related to arywiki only as there are many pages with invalid titles on many other wikis.

For now, a quick workaround for Pywikibot would be to ignore such pages when encountering one. Thank you.