Related endpoint returns 500 if the main item is not found in ES index #3349
Labels
💻 aspect: code
Concerns the software code in the repository
🛠 goal: fix
Bug fix
help wanted
Open to participation from the community
🟨 priority: medium
Not blocking but should be addressed soon
🧱 stack: api
Related to the Django API
Problem
For the related endpoint, we first search for the item in ES index to get its title, tags and creator.
openverse/api/api/controllers/elasticsearch/related.py
Line 30 in 5e55faa
When the
identifier
part of the URL matches the UUID regex, but there's no media item with such anidentifier
, this request doesn't return anything, so this request returns 500 ("Could not find items"). It should return 404 instead, usingraise APIException("Not found.", 404)
Description
If the ES request does not return the item, we should return a 404 error.
The text was updated successfully, but these errors were encountered: