From e803a348ec7d6b9f53b342ddbcec61495c740d60 Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Thu, 10 Oct 2024 13:28:29 +0100 Subject: [PATCH] Gracefully handles missing mapping fields There are some instances where mapping fields is missing --- src/middleware/datasetOverview.middleware.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middleware/datasetOverview.middleware.js b/src/middleware/datasetOverview.middleware.js index ac2a747e..ad5818a9 100644 --- a/src/middleware/datasetOverview.middleware.js +++ b/src/middleware/datasetOverview.middleware.js @@ -64,8 +64,8 @@ const fetchEntityCount = fetchOne({ export const prepareDatasetOverviewTemplateParams = (req, res, next) => { const { orgInfo, specification, columnSummary, entityCount, sources, dataset, issues } = req - const mappingFields = columnSummary[0].mapping_field?.split(';') ?? [] - const nonMappingFields = columnSummary[0].non_mapping_field?.split(';') ?? [] + const mappingFields = columnSummary[0]?.mapping_field?.split(';') ?? [] + const nonMappingFields = columnSummary[0]?.non_mapping_field?.split(';') ?? [] const allFields = [...mappingFields, ...nonMappingFields] const numberOfFieldsSupplied = specification.fields.map(field => field.field).reduce((acc, current) => {