From 8189c1bd0f7a61dc8b0482a1224fe1001e94d22d Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Fri, 29 Oct 2021 12:30:27 +0200 Subject: [PATCH] fix(core): Make populator.populateCollections more robust to bad input --- .../data-import/providers/populator/populator.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/src/data-import/providers/populator/populator.ts b/packages/core/src/data-import/providers/populator/populator.ts index 1c0fe0b5ff..fe03f05554 100644 --- a/packages/core/src/data-import/providers/populator/populator.ts +++ b/packages/core/src/data-import/providers/populator/populator.ts @@ -108,7 +108,15 @@ export class Populator { const parent = collectionDef.parentName && collectionMap.get(collectionDef.parentName); const parentId = parent ? parent.id.toString() : undefined; const { assets } = await this.assetImporter.getAssets(collectionDef.assetPaths || []); - + let filters: ConfigurableOperationInput[] = []; + try { + filters = (collectionDef.filters || []).map(filter => + this.processFilterDefinition(filter, allFacetValues), + ); + } catch (e) { + // tslint:disable-next-line:no-console + console.log(e); + } const collection = await this.collectionService.create(ctx, { translations: [ { @@ -122,9 +130,7 @@ export class Populator { parentId, assetIds: assets.map(a => a.id.toString()), featuredAssetId: assets.length ? assets[0].id.toString() : undefined, - filters: (collectionDef.filters || []).map(filter => - this.processFilterDefinition(filter, allFacetValues), - ), + filters, }); collectionMap.set(collectionDef.name, collection); }