From 9df41b6bb849d114f4860e4d700876dadaba5e42 Mon Sep 17 00:00:00 2001
From: Andrew Byrd <andrew@fastmail.net>
Date: Wed, 20 Dec 2023 13:34:26 +0800
Subject: [PATCH] record only one error per job in broker

addresses #919 and #887
---
 .../com/conveyal/analysis/components/broker/Broker.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/main/java/com/conveyal/analysis/components/broker/Broker.java b/src/main/java/com/conveyal/analysis/components/broker/Broker.java
index 2128acf1b..0500df8b4 100644
--- a/src/main/java/com/conveyal/analysis/components/broker/Broker.java
+++ b/src/main/java/com/conveyal/analysis/components/broker/Broker.java
@@ -398,7 +398,11 @@ public synchronized void markTaskCompleted (Job job, int taskId) {
      */
     private synchronized void recordJobError (Job job, String error) {
         if (job != null) {
-            job.errors.add(error);
+            // Limit the number of errors recorded to one.
+            // Still using a Set<String> instead of just String since the set of errors is exposed in a UI-facing API.
+            if (job.errors.isEmpty()) {
+                job.errors.add(error);
+            }
         }
     }