Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-63522] Debug logs are incomplete when From address is invalid #256

Merged
merged 2 commits into from Nov 2, 2020

Conversation

basil
Copy link
Member

@basil basil commented Nov 1, 2020

See JENKINS-63522. When debug logs are enabled and the From address is invalid (for example, if the System Admin e-mail address has not been configured yet in the Jenkins Location section of the Configure System page and is still set to the default value of nobody@nowhere), the outer MessagingException (typically a SendFailedException) is printed to the debug logs but inner exceptions (e.g., SMTPAddressFailedException, SMTPSenderFailedException, or SMTPSendFailedException) are not. The cause is usually found in an inner exception, so it would be helpful to print the inner exceptions to the debug logs when debug logging is enabled.

To test this change, I reproduced the problem and verified that the inner exception is now printed to the debug logs:

Successfully created MimeMessage
Sending email to: test@example.com
Error sending to the following INVALID addresses: test@example.com
SendFailedException message: Invalid Addresses
Next SMTPAddressFailedException message: 553 5.1.8 <test@example.com>... Domain of sender address nobody@nowhere does not exist

@basil basil added the bug label Nov 1, 2020
@rvernica
Copy link

rvernica commented Nov 1, 2020

Note that the log line:

Error sending to the following INVALID addresses: test@example.com

is still misleading since test@example.com is a valid email address!

@basil
Copy link
Member Author

basil commented Nov 1, 2020

Indeed, but this misleading error comes from the JavaMail API itself. I do not know of any way around this that does not rely on implementation details of the JavaMail reference implementation, which I am reticent to do.

@basil
Copy link
Member Author

basil commented Nov 1, 2020

I took a closer look at the API documentation for SendFailedException. Interestingly enough, getValidUnsentAddresses() is described as returning "the addresses that are valid but to which this message was not sent", while getInvalidAddresses() is described merely as returning "the addresses to which this message could not be sent" without implying anything about their validity (beyond the name of the method). I updated the wording used by the Email Extension plugin to conform more closely to the description of the JavaMail API, removing the implication that the return values of getInvalidAddresses() are invalid.

@basil basil merged commit 55ed88e into jenkinsci:master Nov 2, 2020
@basil basil deleted the JENKINS-63522 branch November 20, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants