Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

treat as empty value when json is malformed

Fendy Heryanto018bdf0d9f73
diff --git a/packages/nocodb/src/db/field-handler/handlers/attachment/attachment.general.handler.ts b/packages/nocodb/src/db/field-handler/handlers/attachment/attachment.general.handler.ts
index 8688243a54..40f7b58574 100644
--- a/packages/nocodb/src/db/field-handler/handlers/attachment/attachment.general.handler.ts
+++ b/packages/nocodb/src/db/field-handler/handlers/attachment/attachment.general.handler.ts
@@ -41,14 +41,21 @@ export class AttachmentGeneralHandler extends ComputedFieldHandler {
if (typeof value === 'string') {
value = JSON.parse(value);
} else if (!Array.isArray(value)) {
- throwError();
+ // do not throw error, but set it as empty array
+ value = [];
}
+ } catch (e) {
+ // do not throw error, but set it as empty array
+ value = [];
+ }
+ try {
if (typeof oldValue === 'string') {
oldValue = JSON.parse(oldValue);
}
oldValueMap = new Map(oldValue.map((val) => [val.id, val]));
} catch (e) {
- throwError();
+ // do not throw error, but set it as empty map
+ oldValueMap = new Map();
}
let tempIndex = 1;