From f4d689e431c409d1cc80803aeb0ab87eeb0fb20f Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Sat, 23 Apr 2022 14:49:13 +0200 Subject: [PATCH 1/2] fix: Filter records with missing data and register a warning about it in the Strapi logs. --- server/config/type.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/config/type.js b/server/config/type.js index 06087e6..4578e77 100644 --- a/server/config/type.js +++ b/server/config/type.js @@ -183,6 +183,12 @@ const ConfigType = class ConfigType { await Promise.all(Object.values(AllConfig).map(async (config) => { const combinedUid = getCombinedUid(this.uidKeys, config); const combinedUidWhereFilter = getCombinedUidWhereFilter(this.uidKeys, config); + + if (!combinedUid) { + strapi.log.warn(logMessage(`Missing data for entity with id ${config.id} of type ${this.configPrefix}`)); + return; + } + // Check if the config should be excluded. const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${this.configPrefix}.${combinedUid}`.startsWith(option))); if (shouldExclude) return; From a44db2781df06c3e9b42981bf3fb0544b7014f32 Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Sun, 24 Apr 2022 09:07:18 +0200 Subject: [PATCH 2/2] fix: Warn about an empty config file --- server/services/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/services/main.js b/server/services/main.js index 76d2d22..79f6018 100644 --- a/server/services/main.js +++ b/server/services/main.js @@ -4,6 +4,7 @@ const { isEmpty } = require('lodash'); const fs = require('fs'); const util = require('util'); const difference = require('../utils/getObjectDiff'); +const { logMessage } = require('../utils'); /** * Main services for config import/export. @@ -118,6 +119,12 @@ module.exports = () => ({ } const fileContents = await strapi.plugin('config-sync').service('main').readConfigFile(type, name); + + if (!fileContents) { + strapi.log.warn(logMessage(`An empty config file '${file}' was found in the sync directory`)); + return; + } + fileConfigs[`${type}.${formattedName}`] = fileContents; }));