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

Commit

Permalink
Fix invalid UUID breaking related images query (#766)
Browse files Browse the repository at this point in the history
* Return lower cased license after validation

Signed-off-by: Olga Bulat <[email protected]>

* Add tests

Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat authored Jun 23, 2022
1 parent 7414174 commit 32f5a21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 32f5a21

Please sign in to comment.