Page MenuHomePhabricator

Video2commons fails with Object of type bytes is not JSON serializable
Closed, ResolvedPublic

Description

I tried to upload https://martin.urbanec.cz/files/wmf-rehosting/Conversation%20with%20the%20Wikimedia%20Foundation%20Board%20of%20Trustees%2010-20-21.webm (from this URL) via video2commons, to test a bug @elappen-WMF reported to me off-Phab.

I can't get past this screen:

image.png (240×575 px, 5 KB)

Network tab shows that the POST request to https://video2commons.toolforge.org/api/task/run with the following parameters:

step=confirm
url=https://martin.urbanec.cz/files/wmf-rehosting/Conversation%20with%20the%20Wikimedia%20Foundation%20Board%20of%20Trustees%2010-20-21.webm
extractor=Generic
audio=true
video=true
subtitles=true
filename=Conversation with the Wikimedia Foundation Board of Trustees 10-20-21
formats[]=ogv (Theora/Vorbis)
formats[]=webm (VP8/Vorbis)
formats[]=webm (VP9/Opus)
format=webm (VP9/Opus)
filedesc==={{int:filedesc}}==
{{Information
|description={{en|1=The Wikimedia Foundation’s Board of Trustees’ Community Affairs Committee (CAC) [[m:Wikimedia_Foundation_Community_Affairs_Committee/2021-10-20_Conversation_with_Trustees|hosted a conversation with members of the Board of Trustees]] (formerly called an Office Hour) for the community to directly engage with Trustees on October 20, 2021 at 11:00 UTC..}}
|date=2021-10-20
|source={{own}}
|author=[[User:Elappen (WMF)|Elappen (WMF)]]
|permission=
|other versions= [https://www.youtube.com/watch?v=Zpof5J6jjZ4 YouTube]
}}

=={{int:license-header}}==
{{self|cc-by-sa-4.0}}

[[Category:Wikimedia Foundation Board of Trustees]]
filenamechecked=true
filedescchecked=true
_csrf_token=redacted

This is returned as the response:

{
  "error": "An exception occurred: TypeError: bObject of type bytes is not JSON serializable",
  "step": "error",
  "traceback": "Traceback (most recent call last):\n  File \"/data/project/video2commons/www/python/venv/lib/python3.9/site-packages/flask/app.py\", line 1516, in full_dispatch_request\n    rv = self.dispatch_request()\n  File \"/data/project/video2commons/www/python/venv/lib/python3.9/site-packages/flask/app.py\", line 1502, in dispatch_request\n    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n  File \"/data/project/video2commons/www/python/src/../../../video2commons/frontend/api.py\", line 392, in run_task\n    taskid = run_task_internal(filename, (\n  File \"/data/project/video2commons/www/python/src/../../../video2commons/frontend/api.py\", line 419, in run_task_internal\n    redis_publish(update, {taskid: taskid, data: _status(taskid)})\n  File \"/data/project/video2commons/www/python/src/../../../video2commons/frontend/shared.py\", line 48, in redis_publish\n    redisconnection.publish(v2cnotif:+typ, json.dumps(data))\n  File \"/usr/lib/python3.9/json/__init__.py\", line 231, in dumps\n    return _default_encoder.encode(obj)\n  File \"/usr/lib/python3.9/json/encoder.py\", line 199, in encode\n    chunks = self.iterencode(o, _one_shot=True)\n  File \"/usr/lib/python3.9/json/encoder.py\", line 257, in iterencode\n    return _iterencode(o, 0)\n  File \"/usr/lib/python3.9/json/encoder.py\", line 179, in default\n    raise TypeError(fObject of type {o.__class__.__name__} \nTypeError: Object of type bytes is not JSON serializable\n"
}
reformatted traceback
Traceback (most recent call last):
  File "/data/project/video2commons/www/python/venv/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/data/project/video2commons/www/python/venv/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/data/project/video2commons/www/python/src/../../../video2commons/frontend/api.py", line 392, in run_task
    taskid = run_task_internal(filename, (
  File "/data/project/video2commons/www/python/src/../../../video2commons/frontend/api.py", line 419, in run_task_internal
    redis_publish(update, {taskid: taskid, data: _status(taskid)})
  File "/data/project/video2commons/www/python/src/../../../video2commons/frontend/shared.py", line 48, in redis_publish
    redisconnection.publish(v2cnotif:+typ, json.dumps(data))
  File "/usr/lib/python3.9/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(fObject of type {o.__class__.__name__} 
TypeError: Object of type bytes is not JSON serializable

Can you investigate please?