From ba16b2989a43686f9751be9b3c093a82abd2c24d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 28 Oct 2023 16:30:12 +0530 Subject: [PATCH] fix: if invalid json then skip Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index ca4e4b1f41..602018b6e8 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -2517,11 +2517,15 @@ class BaseModelSqlv2 { await col.getColOptions(); // parse data if it's JSON string - const nestedData = - typeof data[col.title] === 'string' - ? JSON.parse(data[col.title]) - : data[col.title]; - + let nestedData; + try { + nestedData = + typeof data[col.title] === 'string' + ? JSON.parse(data[col.title]) + : data[col.title]; + } catch { + continue + } switch (colOptions.type) { case RelationTypes.BELONGS_TO: { @@ -2628,7 +2632,7 @@ class BaseModelSqlv2 { await Promise.all(postInsertOps.map((f) => f())); - response = this.readByPk( + response = this.readByPk( rowId, false, {},