Skip to content

Commit

Permalink
Add try-except for id param check (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
jernestmyers authored Jan 15, 2025
1 parent 59d961c commit a389d8f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions hipposerve/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ async def validation_exception_handler(
user: PotentialLoggedInUser = Depends(PotentialLoggedInUser),
):
requested_item_type = "generic"
if request.url.path.find("collections"):
requested_item_type = "collection"
elif request.url.path.find("products"):
requested_item_type = "product"

requested_id = request.path_params["id"]
return not_found_template(request, requested_item_type, requested_id, user)
requested_id = None
try:
requested_id = request.path_params["id"]
if request.url.path.find("collections"):
requested_item_type = "collection"
elif request.url.path.find("products"):
requested_item_type = "product"
return not_found_template(request, requested_item_type, requested_id, user)
except KeyError:
return not_found_template(request, requested_item_type, requested_id, user)


if SETTINGS.add_cors:
Expand Down

0 comments on commit a389d8f

Please sign in to comment.