denshoproject / ddr-local

Web UI used for interacting with DDR collections and entities on a local machine.
Other
3 stars 0 forks source link

`JSONDecodeError` while deleting transcript File #312

Closed gjost closed 11 months ago

gjost commented 2 years ago
Traceback (most recent call last):
  File "/opt/ddr-local/venv/ddrlocal/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/ddr-local/venv/ddrlocal/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/ddr-local/ddrlocal/webui/decorators.py", line 18, in wrapper
    return f(*args, **kwargs)
  File "/opt/ddr-local/ddrlocal/webui/views/decorators.py", line 18, in inner
    return func(request, *args, **kwargs)
  File "/opt/ddr-local/ddrlocal/storage/decorators.py", line 83, in inner
    return func(request, *args, **kwargs)
  File "/opt/ddr-local/ddrlocal/webui/views/files.py", line 401, in delete
    check_parents(entity, collection)
  File "/opt/ddr-local/ddrlocal/webui/views/files.py", line 86, in check_parents
    if collection.repo_behind():
  File "/opt/ddr-local/venv/ddrlocal/lib/python3.9/site-packages/ddr_cmdln-5.4.4-py3.9.egg/DDR/models/collection.py", line 493, in repo_behind
    def repo_behind( self ):     return dvcs.behind(self.repo_status(), self.repo_states())
  File "/opt/ddr-local/ddrlocal/webui/models.py", line 576, in repo_states
    gs = gitstatus.read(settings.MEDIA_BASE, self.path)
  File "/opt/ddr-local/ddrlocal/webui/gitstatus.py", line 227, in read
    return loads(text)
  File "/opt/ddr-local/ddrlocal/webui/gitstatus.py", line 202, in loads
    syncstatus = json.loads(syncstatus)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)

Exception Type: JSONDecodeError at /ui/file/ddr-densho-1000-486-23-transcript-38568e6abf/delete/
Exception Value: Extra data: line 2 column 1 (char 149)
gjost commented 2 years ago

Somehow the git-status file for ddr-densho-1000 was malformed:

2022-05-06T11:54:47PDT-0700 0:04:57.537486
%%
## master...origin/master [ahead 17]
%%
{"local annex size": "590.65 megabytes", "size of annexed files in working tree": "1.07 gigabytes", "command": "info", "untrusted repositories": [], "success": true, "semitrusted repositories": [{"here": false, "uuid": "00000000-0000-0000-0000-000000000001", "description": "web"}, {"here": false, "uuid": "00000000-0000-0000-0000-000000000002", "description": "bittorrent"}, {"here": false, "uuid": "04d7381d-313c-4d0e-8fac-8e4a191a13c7", "description": "ddr@denshodeb8:/var/www/media/base/ddr-densho-1000"}, {"here": false, "uuid": "0d051a98-de52-43f9-bc7f-ebf4ea53e7c5", "description": "ddr@denshodeb9:/var/www/media/ddr/ddr-densho-1000"}, {"here": false, "uuid": "178dec57-8b31-4356-a620-b0dc038f92f1", "description": "ddr@densho101dev:/var/www/media/ddr/ddr-densho-1000"}, {"here": false, "uuid": "2b4dca25-c186-479d-9e5c-49c8935529a2", "description": "b2"}, {"here": false, "uuid": "598103a3-a0f2-4a13-85f8-23d7af6225ca", "description": "ddr@kinkura:/media/qnfs/kinkura/temp/test/ddr-densho-1000"}, {"here": false, "uuid": "5d6d0469-c612-4311-a1d3-ddfc531c0f40", "description": "ddr@doc:/var/www/media/ddr/ddr-densho-1000"}, {"here": false, "uuid": "6ba98223-2995-490c-ade0-794dd9d3a690", "description": "ddr@ishigura:/media/qnfs/kinkura/temp/rainerworkdir/ddr-densho-1000"}, {"here": false, "uuid": "7f950fe5-9057-408c-94e3-6a43c2991495", "description": "ddr@densho101dev:/var/www/media/ddr/ddr-densho-1000"}, {"here": false, "uuid": "8c7d62b7-4727-4162-ac85-e4f8a9e38ec7", "description": "hq-temp-transfer"}, {"here": false, "uuid": "975fee51-ab7d-42c0-a686-b66fba0c5119", "description": "ddr@densho100:/var/www/media/ddr/ddr-densho-1000"}, {"here": false, "uuid": "b895ecfd-b9c5-4cb0-9dd7-be1bf6adc97b", "description": "linode"}, {"here": false, "uuid": "b97b2014-8d2a-447e-b7c5-5a34a2431ee6", "description": "hq-backup-gold"}, {"here": false, "uuid": "bc266c55-e1d2-4395-bbf9-0feb4670a249", "description": "20180718-hq-buckner"}, {"here": false, "uuid": "c73e2ff8-2b32-49fb-a30f-e73da3a8e22f", "description": "git@mits2:~/repositories/ddr-densho-1000.git"}, {"here": true, "uuid": "f67a4808-c360-4dd0-bf53-e3511b75964d", "description": "qnfs"}], "input": [], "bloom filter size": "32 mebibytes (5% full)", "backend usage": {"SHA256E": 13885}, "transfers in progress": [], "error-messages": [], "local annex keys": 25241, "available local disk space": "9.37 terabytes (+1 megabyte reserved)", "annexed files in working tree": 13885, "file": null, "trusted repositories": [], "git-annex version": "8.20210223"}
%%
{"timestamp": "2022-05-06T11:54:47PDT-0700", "status": "ahead", "color": "warning", "row": "#ddr-densho-1000", "cell": "#ddr-densho-1000 td.status"}
ng", "row": "#ddr-densho-1000", "cell": "#ddr-densho-1000 td.status"}

Look at the last line - there is a partial copy of the previous line. This in itself would cause a json.loads() parse error, but the last line isn't even a complete JSON document.

gjost commented 2 years ago

Added a slightly more informative error message in commit c14166e but otherwise this is good as it is.