Page MenuHomePhabricator

upload ValueError exception caused by FileInfo
Closed, ResolvedPublic


After an upload a ValueError was caused by FileInfo. This error is happening by the result sent after the file is uploaded (so the file was actually uploaded and is on the wiki). It should contain an imageinfo part similar to action=query&titles=File:Albert Einstein Head.jpg&prop=imageinfo which is a list of dicts. FilePage._load_file_revisions iterates over that list and creates a FileInfo object for each instance by using the returned dict directly. And it seemed that it didn't returned a dict but an iterable containing an iterable with the length 1, something like this:

>>> {}.update([[1]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is required

Original traceback from the tweet:

Sleeping for 8.2 seconds, 2615-65-25 16:52:57
WARNING: API warning (upload): The watch parameter has been deprecated.
Upload successful.
Traceback (most recent call last):
  File “", line 43, in <module>
  File "", line 40, in main
    chunk_size = 1048576)
  File "/home/parker/core/pywikibot/tools/", line 1094, in wrapper
    return obj(‘__args. “__kw)
  File ”/home/parker/core/pywikibot/", line 5889, in upload
  File "/home/parker/core/pywikibot/", line 2665, in _load_file_revisions
    file_revision = FileInfo(file_rev)
  File "[home/parker/core/pywikibot/“, line 4429. in __init__
ValueError: dictionary update sequence element #0 has length 1; 2 is required
<class 'ValueError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort

Follow up:

Event Timeline

jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb added subscribers: jayvdb, Mpaa, Legoktm.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptMay 28 2015, 7:30 AM
XZise set Security to None.
XZise added a subscriber: XZise.

Okay this is odd, I can't upload files to my test wiki which isn't using the most recent version and where I could upload files before. Seems to be a regression.

It's my fault in 31cd9fdc. It assumed the imageinfo from the upload is a list but it's actually just one dict. I'll have a patch shortly.

Change 214423 had a related patch set uploaded (by XZise):
[FIX] APISite.upload: Expect a dict not a list

Change 214423 merged by jenkins-bot:
[FIX] APISite.upload: Expect a dict not a list