-
Notifications
You must be signed in to change notification settings - Fork 1
GET routes/{route_id} #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does %s mean?
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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