Mentorship-android: Internal Server Error in Send Request page

Created on 19 Mar 2020  路  40Comments  路  Source: anitab-org/mentorship-android

Describe the bug
On pressing 'SEND REQUEST' button in Send request page, 'Internal Server Error' is shown in snackar sometimes.

To Reproduce
Steps to reproduce the behavior:

  1. Open the app.
  2. Tap on 'Members' tab. Members page opens.
  3. Tap on any member from the recycler view. Member Profile page opens.
  4. Tap on 'SEND REQUEST' button. Send request page opens.
  5. Tap on 'SEND REQUEST' button again. 'Internal Server Error' is shown.

Expected behavior
If proper mentor-mentee criteria are met, a request should be sent. If mentor-mentee criteria are not properly met, a warning should be shown in snackbar.

Screenshots
yoo
yooo

Smartphone (please complete the following information):

  • Device: Honor 9N
  • OS: Android
  • Browser: Google Chrome
  • Version: 9.1.0.134

Most helpful comment

@mtreacy002 @robotjellyzone Really really indebted to you for helping me out with the issue :).....Actually I got stuck in the backend ..........My bad :(
As mentioned by @mtreacy002 I am joining the stream on SMTP related errors
@mtreacy002 @robotjellyzone Since the motive of open sourcing is learning, I really appreciate the inputs from you guys.......was a lot of learning for me.........Thank you so much guys for updating the issue.......you guys are further welcome to discuss on this issue, if any :)

All 40 comments

@m-murad @isabelcosta May I work on this issue?

@Mehulipal do you know what the cause is for this bug?

Hi @isabelcosta @Mehulipal i think i found the cause of the error/bug [but still not the solution] , I ran that backend code i found the error as shown in the following :

2020-04-16

I think this is the cause of getting internal server error , I think the presence of , [comma] at the end of the json object returned is the error or may be comma is missing somewhere due which it is not being decoded by it but i am still not sure though ....
I am still trying to find that in the backend code .. and will revert back if i found that in code @isabelcosta

Hi @Mehulipal, @robotjellyzone and @isabelcosta. I think I may have found the bug (at least in my testing these things happened).
It might be because of the default mail used in your testing (not sure if you're testing with local or dev environment. Maybe the mail inbox you're using is full or something).
I said this because of these things:

  • when I used gmail as default email, it resulted in internal server error (expected behaviour since I have Gmail security settings as high). But if we could give a specific response to the actual cause (like HTTPStatus.Unauthorized or error 401), it would be better rather than having 'internal server error' message. You can check my PR#527 Backend that caused by the same bug.

Screen Shot 2020-04-18 at 1 19 54 pm

  • when I used the mail.com that has lower security settings and normally shouldn't block the request, I still got an error (which made me surprised too)

Screen Shot 2020-04-18 at 1 21 41 pm

  • Noticed that the error message above (mail.com) was on "Requested action not taken, mailbox is unavailable". Upon further checking to my mail.com, I noticed I have too many unread emails. Coz this is my testing email account anyway, I deleted all the emails in my mailbox (can't be bothered checking how many emails I'm allowed to have in my inbox with them). Then, I ran the test again, this time it was sent successfully.

Screen Shot 2020-04-18 at 1 26 56 pm

So, it's worth checking the mail provider you are using and the process plus error message you received (one of the benefits of testing locally that is you can get this python log to check it out). Your situation might be caused by a different type of errors that triggered SMTPException. Hope this helps.

Hmm.. that's strange @mtreacy002 as i am getting a different error of Failed to decode Json Object at my end while sending request ? 馃

I used swagger to send the request rather than the front end using app... Can you please check at your end using swagger also to confirm this @mtreacy002 ? so, that i can be sure may its only an error at my end ??

I haven't checked on Swagger. But I believe this is due to the fact that the Dao method of mentorship relation (create_mentorship_relation) is supposed to return a string message but the response from SMTP exception is not is Unicode string but a byte sequence as explained here which is why you're getting the JSON decode error. I've tested this by changing my error message to return response as a result of STMP operation,
(edited, placed the wrong error before, 馃槀)

Screen Shot 2020-04-18 at 4 26 13 pm

But when I decode the string response, I got the proper error message:

Screen Shot 2020-04-18 at 3 46 11 pm

This was the code where I was successfully catch the SMTP Error message:

Screen Shot 2020-04-18 at 4 22 30 pm

@isabelcosta , shouldn't we be using this SMTP error responses, after all it is the SMTP process that giving us the error instead of the HTTP? It's just I still haven't figure out how to place the response code message into the namespace (@someentity_ns.response) bcoz I only was able to catch the message after the event was raised the exception, not before... 馃槀

I haven't checked on Swagger. But I believe this is due to the fact that the Dao method of mentorship relation (create_mentorship_relation) is supposed to return a string message but the response from SMTP exception is not is Unicode string but a byte sequence as explained here which is why you're getting the JSON decode error. I've tested this by changing my error message to return response as a result of STMP operation,

raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type bytes is not JSON serializable

But when I decode the string response, I got the proper error message:

Screen Shot 2020-04-18 at 3 46 11 pm

This was the code where I was successfully catch the SMTP Error message:

Screen Shot 2020-04-18 at 4 22 30 pm

You are getting this on while registering the user or while sending request ...? as i can see that from you screenshot that you are getting this Type Error while regsitering the user ... whereas in my case i am just getting this error only while sending the request to the mentor from mentee.....??

Also, I think this error Application-Specific-Password-Required just means that Gmail accounts if used for non-gmail accounts will require some special passwords for their access therefore for such situations you need to set App Passwords if you are using your Gmail account for sending emails as a host mailer...
If you set that app password , you won't be getting this type of error ...

You are getting this on while registering the user or while sending request ...? as i can see that from you screenshot that you are getting this Type Error while regsitering the user ... whereas in my case i am just getting this error only while sending the request to the mentor from mentee.....??

Same concept, both are using SMTP process. The difference is on Registration, my code was using unicode string as response but create_mentorship_relation is using byte string as response.

Also, I think this error Application-Specific-Password-Required just means that Gmail accounts if used for non-gmail accounts will require some special passwords for their access therefore for such situations you need to set App Passwords if you are using your Gmail account for sending emails as a host mailer...
If you set that app password , you won't be getting this type of error ...

On this, I did the gmail on high settings just to reproduce the bug and see the error behaviour on frontend (internal server err) 馃槈. I'll do the same if I want to make/test the create mentorship relation internal with internal server error

Also, I tested the Json error (your bug) by changing my code (Register) on the PR#527-Backend mentioned above bcoz I already changed the code to catch the exception raised by SMTP error. If I want to change the code in this issue, that means I'll have to work on the PR. I just want to avoid conflicts coz Mehuli already asking to work on this PR... 馃槀. I'm merely giving suggestions on how to troubleshoot this issue... 馃槈

I just want you to make sure whether you are also getting the same error[which i am getting] while sending request to create relation ? I didn't made any modification at all .. but still got this error

I can do a quick test now on Swagger, but I have one question though, what did you put as end date? It has to be on Float.... I hate playing with dates-float conversions.... lol 馃槀

I just want you to make sure whether you are also getting the same error[which i am getting] while sending request to create relation ? I didn't made any modification at all .. but still got this error

which environment you are testing this on? local or dev?
also, which email address? if gmail, with high or low settings?

if this (internal server error) happens while you and @Mehulipal testing it on dev environment, it could be that default email used by @isabelcosta has some issue (that does not necessarily caused by gmail security settings as I also faced the same error using mail.com as shown on the test above)

Hmmm.... that's interesting which i was not aware about , i was using dev environment , ok lets see what happens if we use local one... 馃 . are you using local as well ?

Hmmm.... that's interesting which i was not aware about , i was using dev environment , ok lets see what happens if we use local one... 馃 . are you using local as well ?

Yes, I did those tests on local env... 馃槈

wait... I need to cook for the family now... will be back soon.... 馃槀

I'm back... have you give it a try, @robotjellyzone ?

Hi yeah, @mtreacy002 you were right its working on local part , now i am testing and trying to find the reason for getting the Internal Server Error in the frontend part as well !!

Yeah, here is this on the swagger :-
2020-04-18

Hi @Mehulipal i don't know why you were getting this Internal Server Error may be you were testing on Dev [as said by @mtreacy002 ] Try to test it on local part ...

See i am not getting any error :
request sent successfully

Hey @robotjellyzone . My access token won't work. do you know why?

Keeps saying invalid. But I copy paste from when I login as that user. 鈽癸笍

Can you share the screenshot @mtreacy002? May be its not allowing you to login or it may be you didn't confirmed that mail id as earlier you said that you had lot of stack of emails which were unread and may be that's why you didn't read that mail to confirm your id for app

this one, I did confirm the email. This is on local server

this is the error

Screen Shot 2020-04-18 at 7 32 02 pm

and this is my login user and the token

Screen Shot 2020-04-18 at 7 34 11 pm

Screen Shot 2020-04-18 at 7 34 45 pm

and here's the user data in database...

Screen Shot 2020-04-18 at 7 37 42 pm

Hi @mtreacy002 i got it , while you give access token you have to first write Bearer then write/paste your access token !! this will resolve your error !! Even if you see the description which is Authentication access token. E.g.: Bearer then you can see that you have to write Bearer then

hehehehe.... ooo, that's why... I even tried refreshing and clearing the browser beforehand, silly me 鈽猴笍 Thanks, @robotjellyzone . I gave it a try and the message was sent successfully...

Screen Shot 2020-04-18 at 7 45 21 pm

Now I'm gonna try the dev server

Just curious... who did you sent the request to on the dev server?

Hi @mtreacy002 you can create two to three users yourself [by registering different email ids] and then send your request [to yourself 馃槃 ][although seems very weired]

I see what you mean now @robotjellyzone after seeing what @isabelcosta did just now in the Ask Me Anything meeting... 馃槈. Thanks again. So, @Mehulipal , I think we have discussion open now on Zulip chat to discuss about SMTP related errors (just like the one you have here) and their implications on database and potential new features to have. Hope you and @robotjellyzone can join in there to give some suggestions how to move ahead with these related issues (this also dictates the direction on my PR#527 so, it'll be good if we can decide on it pretty soon...

Btw, @Mehulipal, both @robotjellyzone and I think you got the internal server issue due to some internet problems. It might be just a temporarily issue. But regardless, we still need to take precautionary steps on our code to deal with the aftermath of the issue properly (such as resending email ability and not allowing any modification to the database when this thing happens. 馃槈

Thank you for updating the issue @mtreacy002

No worries, @isabelcosta. Glad if I can be of any help to @Mehulipal. Plus this issue relates to my current PR, that's why I'm also curious on why and how to approach it... I'm also happy to collaborate with @robotjellyzone to help with troubleshooting this issue.

@mtreacy002 @robotjellyzone Really really indebted to you for helping me out with the issue :).....Actually I got stuck in the backend ..........My bad :(
As mentioned by @mtreacy002 I am joining the stream on SMTP related errors
@mtreacy002 @robotjellyzone Since the motive of open sourcing is learning, I really appreciate the inputs from you guys.......was a lot of learning for me.........Thank you so much guys for updating the issue.......you guys are further welcome to discuss on this issue, if any :)

Hi @Mehulipal if you think that it was not an issue/bug then feel free to close this issue :) I think @isabelcosta will then remove that label of BUG and Availability status labels as well :)

@robotjellyzone I am wondering, are you able to do this? as part of our open source teams? If you are please be free to do that :) if not I can do it

Oh!! yeah i will do it but its i think good to ask it first to others who added it @isabelcosta , was just taking a kind of permission :) also, should i close it as well ?

Hi @Mehulipal I am closing this issue but If you think that you are still facing this issue then feel free to open this issue again and then we will discuss more on it or you can take the help on zulip as well :)

馃憦 @robotjellyzone

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iofall picture iofall  路  3Comments

isabelcosta picture isabelcosta  路  4Comments

isabelcosta picture isabelcosta  路  6Comments

annabauza picture annabauza  路  6Comments

iofall picture iofall  路  4Comments