From 2994ea09810a461d7a6334cdc4867179d46a08e2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 19 Nov 2017 12:12:10 +0100 Subject: dashboard/app: gracefully handle large error text in emails Build error output and failing VM boot log can be way too long to inline. Inline a part of it and attach full text instead. --- dashboard/app/jobs_test.go | 1 + dashboard/app/mail_test_result.txt | 3 +++ dashboard/app/reporting_email.go | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dashboard/app/jobs_test.go b/dashboard/app/jobs_test.go index 674423201..af997f69b 100644 --- a/dashboard/app/jobs_test.go +++ b/dashboard/app/jobs_test.go @@ -149,6 +149,7 @@ syzbot tried to test the proposed patch but build failed: failed to apply patch + Tested on commit kernel_commit1 repo1/branch1 compiler: compiler1 diff --git a/dashboard/app/mail_test_result.txt b/dashboard/app/mail_test_result.txt index a11442f9a..83009298a 100644 --- a/dashboard/app/mail_test_result.txt +++ b/dashboard/app/mail_test_result.txt @@ -8,6 +8,9 @@ syzbot has tested the proposed patch but the reproducer still triggered crash: syzbot tried to test the proposed patch but build failed: {{printf "%s" .Error}} +{{if .ErrorTruncated}} +Error text is too large and was truncated, full error text is attached. +{{end}} {{else}} syzbot has tested the proposed patch and the reproducer did not trigger crash: diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index fcafd1e9f..ff4bec167 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -164,6 +164,17 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error Data: rep.ReproC, }) } + // Build error output and failing VM boot log can be way too long to inline. + const maxInlineError = 16 << 10 + errorText, errorTruncated := rep.Error, false + if len(errorText) > maxInlineError { + errorTruncated = true + attachments = append(attachments, aemail.Attachment{ + Name: "error.txt", + Data: errorText, + }) + errorText = errorText[:len(errorText)-maxInlineError] + } from, err := email.AddAddrContext(fromAddr(c), rep.ID) if err != nil { return err @@ -180,6 +191,7 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error CrashTitle string Report []byte Error []byte + ErrorTruncated bool HasLog bool HasKernelConfig bool ReproSyz bool @@ -195,7 +207,8 @@ func emailReport(c context.Context, rep *dashapi.BugReport, templ string) error KernelCommit: rep.KernelCommit, CrashTitle: rep.CrashTitle, Report: rep.Report, - Error: rep.Error, + Error: errorText, + ErrorTruncated: errorTruncated, HasLog: len(rep.Log) != 0, HasKernelConfig: len(rep.KernelConfig) != 0, ReproSyz: len(rep.ReproSyz) != 0, -- cgit mrf-deployment