diff --git a/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.test.ts b/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.test.ts index f85eed1523ba8..a59e5f0c32594 100644 --- a/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.test.ts +++ b/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.test.ts @@ -703,6 +703,10 @@ describe('translateUnwiredStreamPipelineActions', () => { .mockImplementationOnce(async () => { return { 'my-template-pipeline': { + created_date_millis: 123456789, + created_date: '2023-10-01T00:00:00.000Z', + modified_date_millis: 123456789, + modified_date: '2023-10-01T00:00:00.000Z', processors: [ { set: { diff --git a/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.ts b/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.ts index 5c8f0e0ac4583..bf557f0a77405 100644 --- a/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.ts +++ b/x-pack/platform/plugins/shared/streams/server/lib/streams/state_management/execution_plan/translate_unwired_stream_pipeline_actions.ts @@ -8,7 +8,7 @@ import type { IngestPipeline } from '@elastic/elasticsearch/lib/api/types'; import type { IScopedClusterClient } from '@kbn/core/server'; import { isNotFoundError } from '@kbn/es-errors'; -import { castArray, groupBy, uniq } from 'lodash'; +import { castArray, groupBy, omit, uniq } from 'lodash'; import { ASSET_VERSION } from '../../../../../common/constants'; import type { ActionsByType, @@ -330,15 +330,29 @@ async function findPipelineToModify( } async function getPipeline(id: string, scopedClusterClient: IScopedClusterClient) { - return scopedClusterClient.asCurrentUser.ingest - .getPipeline({ id }) - .then((response) => response[id]) - .catch((error) => { - if (isNotFoundError(error)) { - return undefined; - } - throw error; - }); + return ( + scopedClusterClient.asCurrentUser.ingest + .getPipeline({ id }) + // some keys on the pipeline can't be modified, so we need to clean them up + // to avoid errors when updating the pipeline + .then((response) => { + if (!response[id]) { + return undefined; + } + return omit(response[id], [ + 'created_date_millis', + 'created_date', + 'modified_date_millis', + 'modified_date', + ]); + }) + .catch((error) => { + if (isNotFoundError(error)) { + return undefined; + } + throw error; + }) + ); } async function getIndexTemplate(name: string, scopedClusterClient: IScopedClusterClient) {