From de948c149efdf2460cdb1ff30fb6362cee47114a Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sat, 20 Jun 2020 15:46:18 +1200 Subject: [PATCH] don't report latestNum of non-existent job navigating to a non-existent job in the frontend caused a mutating change to the buildNums map, and returing the latestNum field caused the frontend to repeatedly try to fetch the latest run, which could overload the backend --- src/laminar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/laminar.cpp b/src/laminar.cpp index 3757830..191d1bf 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -1,5 +1,5 @@ /// -/// Copyright 2015-2019 Oliver Giles +/// Copyright 2015-2020 Oliver Giles /// /// This file is part of Laminar /// @@ -252,7 +252,8 @@ std::string Laminar::getStatus(MonitorScope scope) { j.set("etc", run->startedAt + lastRuntime); }); } - j.set("latestNum", int(buildNums[scope.job])); + if(auto it = buildNums.find(scope.job); it != buildNums.end()) + j.set("latestNum", int(it->second)); j.startArray("artifacts"); populateArtifacts(j, scope.job, scope.num); j.EndArray();