You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
After updating to 2.0.7 from 2.0.6, I now get an ArgumentNullException during a call to AuthenticateAsync. This appears to be due to a null check on the message argument to the AuthenticatedEventArgs constructor that was recently added.
To Reproduce
Steps to reproduce the behavior:
Initialize an ImapClient.
Wire up an empty event handler to the Authenticated event. (The exception does not occur if this is not done.)
Call ConnectAsync to connect to your desired mail server.
Call AuthenticateAsync to authenticate with a server that does not return a proper message.
ArgumentNullException will be thrown.
Workaround
Do not subscribe to the Authenticated event on the mail client, since the exception will not be thrown if the event is not fired in OnAuthenticate.
Suggested fix
line 1305 of MailService.cs, in OnAuthenticated:
handler (this, new AuthenticatedEventArgs (message ?? ""));
(rather than submit a pull request I figured an issue was more appropriate so that you can evaluate if this is the best fix and if this same type of error may have been introduced elsewhere)
Expected behavior
As before, I would expect OnAuthenticated to fire the Authenticated event without an exception. If the Message property needs to be non-null, then either the constructor should set it to an empty string rather than throwing an argument exception, or the MailService should set it before passing a null message to the constructor in the OnAuthenticated method. Possibly something else should be done in ImapClient's AuthenticateAsync method when ic.ResponseText is null, but MailService still needs to handle it gracefully or the potential for the exception would still exist in Pop3Client and SmtpClient as well.
Additional context
I am currently authenticating against FastMail's IMAP server, which may be doing something weird that is causing the message to be null. Nevertheless, I am not really interested in the message but just that authentication completed successfully, so the exception caught me by surprise.
The text was updated successfully, but these errors were encountered:
Describe the bug
After updating to 2.0.7 from 2.0.6, I now get an ArgumentNullException during a call to AuthenticateAsync. This appears to be due to a null check on the message argument to the AuthenticatedEventArgs constructor that was recently added.
To Reproduce
Steps to reproduce the behavior:
Workaround
Do not subscribe to the Authenticated event on the mail client, since the exception will not be thrown if the event is not fired in OnAuthenticate.
Suggested fix
line 1305 of MailService.cs, in OnAuthenticated:
handler (this, new AuthenticatedEventArgs (message ?? ""));
(rather than submit a pull request I figured an issue was more appropriate so that you can evaluate if this is the best fix and if this same type of error may have been introduced elsewhere)
Expected behavior
As before, I would expect OnAuthenticated to fire the Authenticated event without an exception. If the Message property needs to be non-null, then either the constructor should set it to an empty string rather than throwing an argument exception, or the MailService should set it before passing a null message to the constructor in the OnAuthenticated method. Possibly something else should be done in ImapClient's AuthenticateAsync method when ic.ResponseText is null, but MailService still needs to handle it gracefully or the potential for the exception would still exist in Pop3Client and SmtpClient as well.
Additional context
I am currently authenticating against FastMail's IMAP server, which may be doing something weird that is causing the message to be null. Nevertheless, I am not really interested in the message but just that authentication completed successfully, so the exception caught me by surprise.
The text was updated successfully, but these errors were encountered: