Skip to content

IIIF: Specifying an incomplete uuid in the image_base endpoint gives a 500 response #2140

@max-moser

Description

@max-moser

Package version (if known): 19.5.4

Describe the bug

Providing fewer than expected colons for the ID in the IIIF image_base endpoint gives a 500 error.

Steps to Reproduce

  1. Create a record with an image for IIIF
  2. Visit the IIIF image_base endpoint, but with less than two colons in the uuid part of the URL path
  3. See error
Exception on /iiif/record:9tp42-0pk88 [GET]
Traceback (most recent call last):
  File "/var/instance/.venv/lib/python3.13/site-packages/flask/app.py", line 1511, in wsgi_app
    response = self.full_dispatch_request()
  File "/var/instance/.venv/lib/python3.13/site-packages/flask/app.py", line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/var/instance/.venv/lib/python3.13/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/instance/.venv/lib/python3.13/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_resources/resources.py", line 65, in view
    return view_meth()
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_resources/content_negotiation.py", line 116, in inner_content_negotiation
    return f(*args, **kwargs)
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_cors/decorator.py", line 121, in wrapped_function
    resp = make_response(f(*args, **kwargs))
                         ~^^^^^^^^^^^^^^^^^
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_resources/content_negotiation.py", line 116, in inner_content_negotiation
    return f(*args, **kwargs)
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_resources/parsers/decorators.py", line 51, in inner
    return f(self, *args, **kwargs)
  File "/var/instance/.venv/lib/python3.13/site-packages/flask_resources/responses.py", line 39, in inner
    res = f(*args, **kwargs)
  File "/var/instance/.venv/lib/python3.13/site-packages/invenio_rdm_records/resources/iiif.py", line 152, in _wrapper
    return f(self, *args, **kwargs)
  File "/var/instance/.venv/lib/python3.13/site-packages/invenio_rdm_records/resources/iiif.py", line 216, in base
    item = self.service.get_file(
        identity=g.identity,
        uuid=resource_requestctx.view_args["uuid"],
    )
  File "/var/instance/.venv/lib/python3.13/site-packages/invenio_rdm_records/services/iiif/service.py", line 130, in get_file
    type_, id_, key = self._iiif_image_uuid(uuid)
                      ~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/var/instance/.venv/lib/python3.13/site-packages/invenio_rdm_records/services/iiif/service.py", line 63, in _iiif_image_uuid
    type_, id_, key = uuid.split(":", 2)
    ^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 2)

Expected behavior

We receive a 400 response that states that our supplied ID is invalid.

Perhaps we should add this to the request view arg parsing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions