diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/remove.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/remove.ts index 02d5dfc64d07d..5b5583a121e5d 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/remove.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/remove.ts @@ -7,6 +7,7 @@ import { SavedObjectsClientContract } from 'kibana/server'; import { CallESAsCurrentUser, ElasticsearchAssetType, EsAssetReference } from '../../../../types'; import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common/constants'; +import { appContextService } from '../../../app_context'; export const stopTransforms = async (transformIds: string[], callCluster: CallESAsCurrentUser) => { for (const transformId of transformIds) { @@ -28,7 +29,7 @@ export const deleteTransforms = async ( // get the index the transform const transformResponse: { count: number; - transforms: Array<{ + transforms?: Array<{ dest: { index: string; }; @@ -36,6 +37,7 @@ export const deleteTransforms = async ( } = await callCluster('transport.request', { method: 'GET', path: `/_transform/${transformId}`, + ignore: [404], }); await stopTransforms([transformId], callCluster); @@ -46,13 +48,17 @@ export const deleteTransforms = async ( ignore: [404], }); - // expect this to be 1 - for (const transform of transformResponse.transforms) { - await callCluster('transport.request', { - method: 'DELETE', - path: `/${transform?.dest?.index}`, - ignore: [404], - }); + if (transformResponse?.transforms) { + // expect this to be 1 + for (const transform of transformResponse.transforms) { + await callCluster('transport.request', { + method: 'DELETE', + path: `/${transform?.dest?.index}`, + ignore: [404], + }); + } + } else { + appContextService.getLogger().warn(`cannot find transform for ${transformId}`); } }) ); diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/transform.test.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/transform.test.ts index 768c6af1d8915..2bf0ad12856f8 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/transform.test.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/transform/transform.test.ts @@ -160,6 +160,7 @@ describe('test transform install', () => { { method: 'GET', path: '/_transform/endpoint.metadata_current-default-0.15.0-dev.0', + ignore: [404], }, ], [ @@ -446,6 +447,7 @@ describe('test transform install', () => { { method: 'GET', path: '/_transform/endpoint.metadata-current-default-0.15.0-dev.0', + ignore: [404], }, ], [