Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix invalid UUID breaking related images query #766

Merged
merged 2 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/catalog/api/views/media_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def related(self, request, identifier=None, *_, **__):
self.paginator.page_size = 10
except ValueError as e:
raise get_api_exception(getattr(e, "message", str(e)))
# If there are no hits in the search controller
except IndexError:
raise get_api_exception("Could not find items.", 404)

serializer = self.get_serializer(results, many=True)
return self.get_paginated_response(serializer.data)
Expand Down
7 changes: 7 additions & 0 deletions api/test/api_live_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,13 @@ def no_duplicates(xs):
assert no_duplicates(ids)


def test_related_does_not_break():
response = requests.get(
f"{API_URL}/image/related/000000000000000000000000000000000000", verify=False
)
assert response.status_code == 404


@pytest.fixture
def related_factory():
"""
Expand Down