Conversation
This comment was marked as resolved.
This comment was marked as resolved.
| """ | ||
| Get a route by its unique identifier. | ||
|
|
||
| Parameters: | ||
| route_id (UUID): The unique identifier of the route to delete. | ||
| session (AsyncSession): The database session dependency. | ||
|
|
||
| Authentication: | ||
| Requires the user to be authenticated as a driver. | ||
|
|
||
| Returns: | ||
| None. Responds with HTTP 200 OK on successful get. | ||
|
|
||
| Raises: | ||
| HTTPException: | ||
| - 404 Not Found: If the route with the specified ID does not exist. | ||
| - 500 Server Error | ||
| """ |
There was a problem hiding this comment.
It's good that you are leaving docstring, but I think that this might be a little too verbose. Just a description, parameter, and returns are fine. Auth should be evident by reading code and raises can be a quick reference to 404 (500 comes default)!
| - 500 Server Error | ||
| """ | ||
|
|
||
| # TODO: the auth here does not work, I think this is an auth issue |
There was a problem hiding this comment.
Remove To Do, good catch, and I will make sure to address this soon.
|
|
||
| if not route: | ||
| self.logger.error(f"Route with id {route_id} not found") | ||
| raise ValueError(f"Route with id {route_id} not found") | ||
|
|
There was a problem hiding this comment.
I think this error handling would raise a 500 Internal Server Error rather than a 404. It would be better to do something like:
raise HTTPException(
status_code=404,
detail=f"Route with id {route_id} not found"
)
|
|
||
| return route | ||
| except Exception as error: | ||
| self.logger.exception("Failed to get route %s", route_id) |
| except Exception as error: | ||
| self.logger.error(f"Failed to delete route {route_id}: {error!s}") | ||
| await session.rollback() | ||
| # TODO: do we really want to return the raw error |
There was a problem hiding this comment.
Should be good for now! There might be logging that is done at a level above; this just raises an error.
JIRA ticket link
Ticket Name
Implementation description
Steps to test
What should reviewers focus on?
Checklist