mentorship-backend
mentorship-backend copied to clipboard
Fix: refactor HTTP error codes PUT /mentorship_relation/{request_id}/task/{task_id}/comment/{comment_id}
Description
As a GSoC student, I need the correct HTTP error response code to be returned accordingly by Mentorship System API in relation to PUT /mentorship_relation/{request_id}/task/{task_id}/comment/{comment_id}, so that I can represent the error message accordingly to both Mentorship System and Bridge In Tech users.
Mocks
NA
Acceptance Criteria
Update [Required]
- [ ] 403: Forbidden needs to be returned instead of 400: Bad Request if it has unaccepted state relation or the relation is not created by the user.
Enhancement to Update [Optional]
NA
Definition of Done
- [ ] All of the required items are completed.
- [x] Approval by 1 mentor.
Estimation
1 hour
I would like to work on this issue.
Yes sure! I will assign it to you @gaurivn :)
@mtreacy002, @isabelcosta, I couldn't find PUT /mentorship_relation/{request_id}/task/{task_id}/comment/{comment_id} I could find only the below which closely resembles the issue
- PUT /mentorship_relation/{relation_id}/task/{task_id}/comment/{comment_id} (3rd in below screenshot)
- PUT /mentorship_relation/{request_id}/task/{task_id}/complete (12th in below screenshot)
Attaching the screenshot below, please take a look and tell me if there are any changes to this issue
The remaining four are GET
@gaurivn 1st option is the correct :)
Thank you, will send in a PR soon
Adding first-timers-only
as this is relatively easy issue
@devkapilbansal can I be assigned this
it's yours now @RiddhiAthreya :) Let us know if you have any doubts 🤗
Hi @mtreacy002 I wanna know why Forbidden should be returned instead of Bad Request? If I am not wrong, Forbidden is returned when the user doesn't have permissions to perform an operation
@devkapilbansal , as per the httpstatuses.com, 400 is used when the user sent the wrong payload (whether it's syntax/request fields related or routing) that are not accepted by the endpoint. 403 on the other hand, the system understood the request (no error in payload) but refused to authorise it since there is a condition that is not met. In the case of this endpoint, the user who sends the request is not involved in the relation linked to the task_id, or if user was involved in the relation but the status of the relationship between mentor and mentee is other than accepted (pending, rejected, cancel, etc), these will make the requested operation cannot be authorised by the system under those conditions. Hope this makes sense 😉