From 1424355b3e0650cb5b31558e232e8a0fe649e4c2 Mon Sep 17 00:00:00 2001 From: Cesar Varela Date: Thu, 14 Sep 2023 15:33:23 -0300 Subject: [PATCH] Prevent tool from crashing if the classification is missing attributes. --- .../{mongodbAiidprodIncidents.incident_id}.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js index d39655990e..a83414802d 100644 --- a/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js +++ b/site/gatsby-site/src/pages/apps/csettool/{mongodbAiidprodIncidents.incident_id}.js @@ -34,13 +34,15 @@ const ToolPage = (props) => { }; for (const classification of data.classifications) { - const json = classification.attributes.find( - (a) => a.short_name == attribute.short_name - ).value_json; + const item = classification.attributes.find((a) => a.short_name == attribute.short_name); - const value = JSON.parse(json); + if (item) { + const value = JSON.parse(item.value_json); - row[classification.namespace] = value; + row[classification.namespace] = value; + } else { + row[classification.namespace] = null; + } } rows.push(row);