From 684dccae037bc3fbb4388e174ae40ddd5b91cee7 Mon Sep 17 00:00:00 2001 From: jbyrne Date: Mon, 17 Jun 2024 13:28:15 -0700 Subject: [PATCH] issue/hitide-profile-45: fixed parsing error for history --- server/util/history-db.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/util/history-db.js b/server/util/history-db.js index d725194..3eac8e8 100644 --- a/server/util/history-db.js +++ b/server/util/history-db.js @@ -91,7 +91,15 @@ function convertDbJobToJsJob(dbJob) { } if(jsonProperties[jsKey]) { - value = JSON.parse(value); + // if string is not valid json, convert it to valid json. + try { + value = JSON.parse(value); + } catch(error) { + if(dbKey === 'download_urls') { + value = ['https://harmony.earthdata.nasa.gov/jobs/' + dbJob['token']] + } + } + } jsJob[jsKey] = value;