Page MenuHomePhabricator

unusedfiles fails on Flow talk pages
Closed, ResolvedPublic

Description

Running

py -3.11 -m pwb -simulate unusedfiles -lang:ur

leads to a ValueError on Flow talk pages

18 read operations
32 write operations
Execution time: 44 seconds
Read operation time: 2.4 seconds
Write operation time: 1.4 seconds
Script terminated by exception:

ERROR: not enough values to unpack (expected 2, got 1) (ValueError)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\pwb\GIT\core\pwb.py", line 40, in <module>
    sys.exit(main())
             ^^^^^^
  File "D:\pwb\GIT\core\pwb.py", line 36, 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 523, in <module>
    main()
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 507, in main
    if not execute():
           ^^^^^^^^^
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 494, in execute
    run_python_file(filename, script_args, module)
  File "D:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 149, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "D:\pwb\GIT\core\scripts\unusedfiles.py", line 204, in <module>
    main()
  File "D:\pwb\GIT\core\scripts\unusedfiles.py", line 198, in main
    bot.run()
  File "D:\pwb\GIT\core\pywikibot\bot.py", line 1582, in run
    self.treat(page)
  File "D:\pwb\GIT\core\scripts\unusedfiles.py", line 133, in treat
    self.post_to_flow_board(usertalkpage, msg2uploader)
  File "D:\pwb\GIT\core\scripts\unusedfiles.py", line 162, in post_to_flow_board
    header, rest = post.split('\n', 1)
    ^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
CRITICAL: Exiting due to uncaught exception ValueError: not enough values to unpack (expected 2, got 1)

D:\pwb\GIT\core>

The reason of this failure is that the message should be substed but API:Expandtemplates does not work with preleading subst: and just gives the message back. This is ok for normal talk pages but fails with StructuredDiscussions because the expanded template is expected to split the topic /header from the content. For example the expanded text from '{{اطلاع برائے غیر مستعمل تصاویر|%(title)s}}' % {'title': '### foo bar ###'} gives

"== غیر مستعمل تصویر ==\n[[image:Ambox warning_pn.svg|48px|right]]\nسلام '''API'''! میں ایک [[خودکار صارف]] ہوں؛ اردو ویکیپیڈیا کے جائزہ کے دوران میں مجھے پتہ چلا کہ آپ کی اپلوڈ کردہ [[:### foo bar ###]] کسی جگہ مستعمل نہیں ہے، لہذا آپ سے گزارش ہے کہ اپنی تصاویر کو [[commons:|ویکیمیڈیا کامنز]] پر اپلوڈ کریں۔ چونکہ ویکیپیڈیا میں '''ناقابل استعمال تصویر''' کو اپلوڈ کرنے کی ممانعت ہے اور '''ایسی تصاویر جو کسی بھی جگہ مستعمل نہ ہوں ایک ماہ کے اندر حذف کردی جاتی ہیں'''، اس لیے مذکورہ مسئلہ آپ کی فوری توجہ کا طالب ہے۔<br />\nاگر آپ کے خیال میں یہ پیغام غلط ہے تو [[تبادلۂ خیال صارف:محمد شعیب|یہاں]] رابطہ کریں، شکریہ۔"

which can be splitted into header and content. but the unexpanded {{subst:...}} leads to that ValueError

See also T108969, T371180

Event Timeline

Xqt changed the task status from Open to In Progress.Aug 14 2024, 2:30 PM
Xqt triaged this task as Medium priority.

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

[pywikibot/core@master] unusedfiles: remove Flow support

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

Change #1062743 merged by jenkins-bot:

[pywikibot/core@master] unusedfiles: remove Flow support

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