aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-08-07 11:25:04 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-08-07 09:38:25 +0000
commit0ef3dfda5198308f6ac51717bb46a081e465a7ff (patch)
tree0f69400d0dd7a6031b2da7d6e09b77e231c7f154
parent4ffcc9efeba621d9391f2beb81ab904c2f97cefa (diff)
dashboard: fix a nil pointer dereference
If bug's origin has not yet been determined, the dashboard app might crash with "panic: runtime error: invalid memory address or nil pointer dereference" at dashboard/app/tree.go:740. Fix this and add a test.
-rw-r--r--dashboard/app/tree.go4
-rw-r--r--dashboard/app/tree_test.go13
2 files changed, 17 insertions, 0 deletions
diff --git a/dashboard/app/tree.go b/dashboard/app/tree.go
index 07c289ea7..da30a74b6 100644
--- a/dashboard/app/tree.go
+++ b/dashboard/app/tree.go
@@ -737,6 +737,10 @@ func crossTreeBisection(c context.Context, bug *Bug,
log.Infof(c, "%s: considering cross-tree bisection %s/%s",
bug.displayTitle(), from.repo.Alias, to.repo.Alias)
_, crashJob := bug.findResult(c, to.repo, wantNewAny{}, runOnHEAD{})
+ if crashJob == nil {
+ // No patch testing was performed yet.
+ return nil
+ }
if crashJob.CrashTitle == "" {
// The bug is already fixed on the target tree.
return nil
diff --git a/dashboard/app/tree_test.go b/dashboard/app/tree_test.go
index e5ef649c6..f5230f7f8 100644
--- a/dashboard/app/tree_test.go
+++ b/dashboard/app/tree_test.go
@@ -293,6 +293,19 @@ For information about bisection process see: %URL%#bisection
assert.Len(t, bug.Commits, 0)
}
+func TestTreeBisectionBeforeOrigin(t *testing.T) {
+ c := NewCtx(t)
+ defer c.Close()
+
+ ctx := setUpTreeTest(c, downstreamUpstreamRepos)
+ ctx.uploadBug(`https://downstream.repo/repo`, `master`, dashapi.ReproLevelC)
+ ctx.reportToEmail()
+ // Ensure the job is no longer created.
+ ctx.ctx.advanceTime(time.Hour)
+ job := ctx.client.pollSpecificJobs(ctx.manager, dashapi.ManagerJobs{BisectFix: true})
+ assert.Equal(t, "", job.ID)
+}
+
func TestTreeOriginErrors(t *testing.T) {
c := NewCtx(t)
defer c.Close()