viur-framework / viur-core

The core component of ViUR, the Python framework for modern web development.
https://www.viur.dev
MIT License
13 stars 14 forks source link

fix: `File.parse_download_url()`: `too many values to unpack` #1287

Closed phorward closed 1 month ago

phorward commented 1 month ago

Truly amazing that this bug has not yet surfaced in the entire, huge, worldwide ViUR community with its thousands of projects... wow. It seems that none of those millions or trillions of projects worldwide have ever saved a TextBone with a link to a local file.

[2024-10-15 22:55:09,930] /.../viur/core/request.py:331 [ERROR] ViUR has caught an unhandled exception!
[2024-10-15 22:55:09,930] /.../viur/core/request.py:332 [ERROR] too many values to unpack (expected 2)
Traceback (most recent call last):
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/request.py", line 306, in _process
    self._route(path)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/request.py", line 565, in _route
    res = caller(*self.args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/module.py", line 301, in __call__
    return self._func(self._instance, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/prototypes/list.py", line 258, in edit
    skel.toDB()  # write it!
    ^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/skeleton.py", line 1186, in toDB
    key, db_obj, skel, change_list, is_add = db.RunInTransaction(__txn_update, skel)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/viur/datastore/transport.pyx", line 819, in viur.datastore.transport.RunInTransaction
  File "src/viur/datastore/transport.pyx", line 816, in viur.datastore.transport.RunInTransaction
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/skeleton.py", line 1008, in __txn_update
    blob_list.update(bone.getReferencedBlobs(skel, bone_name))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/text.py", line 421, in getReferencedBlobs
    collector.feed(value)
  File "/usr/lib/python3.12/html/parser.py", line 111, in feed
    self.goahead(0)
  File "/usr/lib/python3.12/html/parser.py", line 171, in goahead
    k = self.parse_starttag(i)
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/html/parser.py", line 338, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/text.py", line 74, in handle_starttag
    if file and (filepath := file.parse_download_url(v)):
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/modules/file.py", line 513, in parse_download_url
    dlpath, valid_until = data.split("\0")
    ^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)