From b13c272f114bf1d1ad2482fb0acf70b4569d5df8 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Tue, 27 Jun 2023 09:34:47 +0200 Subject: [PATCH] Fix undefined model case --- packages/core/utils/src/content-types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/utils/src/content-types.ts b/packages/core/utils/src/content-types.ts index 8c9ef46269..7118c78d6c 100644 --- a/packages/core/utils/src/content-types.ts +++ b/packages/core/utils/src/content-types.ts @@ -53,6 +53,8 @@ const getTimestamps = (model: Model) => { }; const getNonWritableAttributes = (model: Model) => { + if (!model) return []; + const nonWritableAttributes = _.reduce( model.attributes, (acc, attr, attrName) => (attr.writable === false ? acc.concat(attrName) : acc), @@ -63,6 +65,8 @@ const getNonWritableAttributes = (model: Model) => { }; const getWritableAttributes = (model: Model) => { + if (!model) return []; + return _.difference(Object.keys(model.attributes), getNonWritableAttributes(model)); };