aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-02-26 15:37:32 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-02-26 16:27:33 +0100
commit2e1b81398b5442bb1f12ed2c6aa0286516fe73a6 (patch)
tree3dddd7045a210b4be3b7ccd4abffa3fe99c77ef8
parent773431cfd06efb5bb9e299bd9b738bd3e1c78377 (diff)
dashboard/app: extend email reply when bug is not found
We currently reply with a very minimalistic reply that is not too actionable. Explain what exactly happened and how to fix it.
-rw-r--r--dashboard/app/email_test.go33
-rw-r--r--dashboard/app/reporting_email.go22
2 files changed, 53 insertions, 2 deletions
diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go
index 3cc0cb5f4..1fd6a81e8 100644
--- a/dashboard/app/email_test.go
+++ b/dashboard/app/email_test.go
@@ -538,3 +538,36 @@ func TestEmailCrossReportingDup(t *testing.T) {
}
}
}
+
+func TestEmailErrors(t *testing.T) {
+ c := NewCtx(t)
+ defer c.Close()
+
+ // No reply for email without bug hash and no commands.
+ c.incomingEmail("syzbot@testapp.appspotmail.com", "Investment Proposal")
+ c.expectOK(c.GET("/email_poll"))
+ c.expectEQ(len(c.emailSink), 0)
+
+ // If email contains a command we need to reply.
+ c.incomingEmail("syzbot@testapp.appspotmail.com", "#syz invalid")
+ reply := c.pollEmailBug()
+ c.expectEQ(reply.To, []string{"<default@sender.com>"})
+ c.expectEQ(reply.Body, `> #syz invalid
+
+I see the command but can't find the corresponding bug.
+Please resend the email to syzbot+HASH@testapp.appspotmail.com address
+that is the sender of the bug report (also present in the Reported-by tag).
+
+`)
+
+ c.incomingEmail("syzbot+123@testapp.appspotmail.com", "#syz invalid")
+ reply = c.pollEmailBug()
+ c.expectEQ(reply.Body, `> #syz invalid
+
+I see the command but can't find the corresponding bug.
+The email is sent to syzbot+HASH@testapp.appspotmail.com address
+but the HASH does not correspond to any known bug.
+Please double check the address.
+
+`)
+}
diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go
index 9707b9e03..2b6ffdc2f 100644
--- a/dashboard/app/reporting_email.go
+++ b/dashboard/app/reporting_email.go
@@ -51,6 +51,14 @@ const (
replySubjectPrefix = "Re: "
commitHashLen = 12
commitTitleLen = 47 // so that whole line fits into 78 chars
+
+ replyNoBugID = "I see the command but can't find the corresponding bug.\n" +
+ "Please resend the email to %[1]v address\n" +
+ "that is the sender of the bug report (also present in the Reported-by tag)."
+ replyBadBugID = "I see the command but can't find the corresponding bug.\n" +
+ "The email is sent to %[1]v address\n" +
+ "but the HASH does not correspond to any known bug.\n" +
+ "Please double check the address."
)
var mailingLists map[string]bool
@@ -417,7 +425,12 @@ func loadBugInfo(c context.Context, msg *email.Email) (bug *Bug, bugReporting *B
log.Infof(c, "no bug ID (%q)", msg.Subject)
} else {
log.Errorf(c, "no bug ID (%q)", msg.Subject)
- if err := replyTo(c, msg, "Can't find the corresponding bug.", nil); err != nil {
+ from, err := email.AddAddrContext(ownEmail(c), "HASH")
+ if err != nil {
+ log.Errorf(c, "failed to format sender email address: %v", err)
+ from = "ERROR"
+ }
+ if err := replyTo(c, msg, fmt.Sprintf(replyNoBugID, from), nil); err != nil {
log.Errorf(c, "failed to send reply: %v", err)
}
}
@@ -426,7 +439,12 @@ func loadBugInfo(c context.Context, msg *email.Email) (bug *Bug, bugReporting *B
bug, _, err := findBugByReportingID(c, msg.BugID)
if err != nil {
log.Errorf(c, "can't find bug: %v", err)
- if err := replyTo(c, msg, "Can't find the corresponding bug.", nil); err != nil {
+ from, err := email.AddAddrContext(ownEmail(c), "HASH")
+ if err != nil {
+ log.Errorf(c, "failed to format sender email address: %v", err)
+ from = "ERROR"
+ }
+ if err := replyTo(c, msg, fmt.Sprintf(replyBadBugID, from), nil); err != nil {
log.Errorf(c, "failed to send reply: %v", err)
}
return nil, nil, nil