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:
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


Smartphone (please complete the following information):
@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 :

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:



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, 馃槀)

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

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

@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 serializableBut when I decode the string response, I got the proper error message:
This was the code where I was successfully catch the SMTP Error message:
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 :-

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 :

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

and this is my login user and the token


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

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
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...

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
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 :)