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

Filtering relations with invalid relation_state returns an empty list instead of error message

Open isabelcosta opened this issue 5 years ago • 19 comments

Describe the bug

When relation_state is a number (invalid filter) the API returns an empty list instead of a dictionary with an error message.

To Reproduce

Pre-requisite: have a user registered

Steps to reproduce the behavior:

  1. Login the user
  2. Access GET /mentorship_relations and filter by relation_state, with the value 2
  3. See the empty list as the response and 400 HTTP error code.

Expected behavior

If the HTTP code is 400, for BAD REQUEST, I think the response should contain a message explaining that the relation_state filter is not valid.

Screenshots

Screenshot with 400 BAD REQUEST and an empty list being returned when relation_state have value 2.

Screenshot 2020-02-15 at 19 07 31

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: Chrome
  • Version 🤷‍♀

Additional context

🤷‍♀

isabelcosta avatar Feb 17 '20 20:02 isabelcosta

Is this a bug? Does this make sense? Should it continue to be an empty list?! Asking for opinion @annabauza @BadduCoder

isabelcosta avatar Feb 17 '20 20:02 isabelcosta

Yeah @isabelcosta , It would be better if an error is returned. We don't want it to be considered as "There are no requests currently". Because in that case too, list would be empty.

sumit-badsara avatar Feb 20 '20 13:02 sumit-badsara

@isabelcosta I would like to work on this!

PratibhaShrivastav avatar Feb 20 '20 14:02 PratibhaShrivastav

@isabelcosta It Shows internal server error while registering for a new user,and while executing again it show error 400 username already exists. I think it is not able to send email. Screenshot from 2020-02-21 14-47-49

srivastava9 avatar Feb 21 '20 09:02 srivastava9

@PratibhaShrivastav sure you can work on this :)

isabelcosta avatar Feb 22 '20 22:02 isabelcosta

@srivastava9 you are correct. Sometimes we have this issue, and it is related to Gmail security settings, that can be wrongly set. This problem is explained in issue #233. I think I fixed the issue in the email we used to send emails, and once the server comes back up I think this will be solved. Thank you for reporting this bug @srivastava9 :)

isabelcosta avatar Feb 22 '20 22:02 isabelcosta

@isabelcosta I tried returning a dictionary with error message stated but while debugging i found that due to us using mashal_list_with functionality from flask for returning json array of mentorship relations we cannot do much about it without replacing the logic for returning relations. Screenshot from 2020-02-27 01-42-17

Screenshot from 2020-02-27 01-27-13

SanujBansal avatar Feb 26 '20 20:02 SanujBansal

@isabelcosta I want to work on this issue.

satya7289 avatar Mar 03 '20 17:03 satya7289

@isabelcosta, I don't know if this can be considered as a bug. Because perhaps relation_id = 2 (Accepted) is considered not a request anymore? I tried to run this on the Android UI and it doesn't seem to be anything wrong. So, this is what I've done.

  • user testtwo sent request to testone and got accepted, they are now in relationship
  • as user testtwo, if I look at my Requests tab, I have options: Pending, Past and All (I'm pretty sure 'All' means both Pending and Past, so not including current). At the time I did the test, I have no pending or past request.
Screen Shot 2020-04-03 at 3 37 52 pm
  • But since I have 'currently' one mentorship relation, I can see it inside my 'Relation' tab (this shows 'Current Relation'.
Screen Shot 2020-04-03 at 3 32 38 pm

ATM, we're only allowed to have one mentorship relation at a time, I think this is an expected behaviour? But even if we have more than one relation at a time, shouldn't it still best not to display accepted requests in the 'Requests' tab but in the 'Relation' tab?

This is just my thoughts.... 😉 . What do you all think?

mtreacy002 avatar Apr 03 '20 04:04 mtreacy002

But then I noticed this, for a user who has no current relation and tried to send requests to more than one person (to widen their chance perhaps... 😀 ), only the last request got recorded and the previous one didn't (in my test I sent 2 requests). I think we can consider this as a bug then, coz the expected behaviour is for the all requests to be shown in 'Pending' and 'All' list.

Screen Shot 2020-04-03 at 4 12 54 pm

Screen Shot 2020-04-03 at 4 12 36 pm Screen Shot 2020-04-03 at 4 26 32 pm

mtreacy002 avatar Apr 03 '20 05:04 mtreacy002

But then I noticed this, for a user who has no current relation and tried to send requests to more than one person (to widen their chance perhaps... 😀 ), only the last request got recorded and the previous one didn't (in my test I sent 2 requests). I think we can consider this as a bug then, coz the expected behaviour is for the all requests to be shown in 'Pending' and 'All' list. (...)

Can you clarify what happened? there are 2 requests in the pending state but only one is shown both in the Pending and All tabs? @mtreacy002

isabelcosta avatar Apr 05 '20 21:04 isabelcosta

So right now, a user can only be in only mentorship relation at a time (in the ACCEPTED state). And if I am not mistaken from the backend API, all requests should be fetched including the Accepted one, but in the Android UI we may filter the current one, since its shown in a specific screen.

@mtreacy002 from the message above the one I quoted, what are yous suggestions?

isabelcosta avatar Apr 05 '20 21:04 isabelcosta

@isabelcosta I would like to work on this!

I have solved this problem now. So I can send the PR right away!

sih99 avatar Apr 16 '20 12:04 sih99

@hongsungin92 this is not assigned to you yet, and I see I lost some messages from previous contributors who are interested, let me ask them first if they still wish to work on this.

isabelcosta avatar Apr 16 '20 13:04 isabelcosta

@PratibhaShrivastav are you still interested in working on this issue? I forgot to assign this to you at the time. let me know if this is not the case and I can assign it to someone else.

@srivastava9 @SanujBansal are you still interested?

isabelcosta avatar Apr 16 '20 13:04 isabelcosta

oh I see..! please check and let me know :)

sih99 avatar Apr 16 '20 13:04 sih99

@isabelcosta can I work on this issue?

chahat99 avatar Apr 18 '20 21:04 chahat99

@hongsungin92 are you still interested? Since I got no answers so far, I can totally assign this to you :)

@chahat99 let me check first with @hongsungin92

isabelcosta avatar Apr 19 '20 13:04 isabelcosta

@isabelcosta yes! I am still interested in this issue:)

sih99 avatar Apr 19 '20 15:04 sih99