mentorship-backend icon indicating copy to clipboard operation
mentorship-backend copied to clipboard

Fix: refactor HTTP error codes PUT /mentorship_relation/{request_id}/task/{task_id}/comment/{comment_id}

Open mtreacy002 opened this issue 4 years ago • 10 comments

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

mtreacy002 avatar Jun 04 '20 14:06 mtreacy002

I would like to work on this issue.

gaurivn avatar Jul 20 '20 23:07 gaurivn

Yes sure! I will assign it to you @gaurivn :)

isabelcosta avatar Jul 20 '20 23:07 isabelcosta

@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

  1. PUT /mentorship_relation/{relation_id}/task/{task_id}/comment/{comment_id} (3rd in below screenshot)
  2. 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 Screenshot from 2020-07-21 20-39-42 The remaining four are GET

gaurivn avatar Jul 21 '20 16:07 gaurivn

@gaurivn 1st option is the correct :)

isabelcosta avatar Jul 21 '20 20:07 isabelcosta

Thank you, will send in a PR soon

gaurivn avatar Jul 21 '20 20:07 gaurivn

Adding first-timers-only as this is relatively easy issue

devkapilbansal avatar Mar 20 '21 08:03 devkapilbansal

@devkapilbansal can I be assigned this

RiddhiAthreya avatar Jun 25 '21 11:06 RiddhiAthreya

it's yours now @RiddhiAthreya :) Let us know if you have any doubts 🤗

isabelcosta avatar Jun 26 '21 20:06 isabelcosta

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 avatar Jul 03 '21 11:07 devkapilbansal

@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 😉

mtreacy002 avatar Jul 03 '21 13:07 mtreacy002