diff --git a/x-pack/plugins/lists/server/routes/utils/remove_templates_if_exist.ts b/x-pack/plugins/lists/server/routes/utils/remove_templates_if_exist.ts index 1394c628eba7b..ac761b5779048 100644 --- a/x-pack/plugins/lists/server/routes/utils/remove_templates_if_exist.ts +++ b/x-pack/plugins/lists/server/routes/utils/remove_templates_if_exist.ts @@ -8,9 +8,10 @@ import { ListClient } from '../../services/lists/list_client'; export const removeLegacyTemplatesIfExist = async (lists: ListClient): Promise => { - const legacyTemplateExists = await lists.getLegacyListTemplateExists(); - const legacyTemplateListItemsExists = await lists.getLegacyListItemTemplateExists(); try { + const legacyTemplateExists = await lists.getLegacyListTemplateExists(); + const legacyTemplateListItemsExists = await lists.getLegacyListItemTemplateExists(); + // Check if the old legacy lists and items template exists and remove it if (legacyTemplateExists) { await lists.deleteLegacyListTemplate(); @@ -19,7 +20,8 @@ export const removeLegacyTemplatesIfExist = async (lists: ListClient): Promise