From dfaacb21aa426faa22c16118bb6be029100320b9 Mon Sep 17 00:00:00 2001 From: Milton Hultgren Date: Tue, 12 Aug 2025 13:11:17 +0200 Subject: [PATCH] [Streams] Remove managed index template properties from PUT request (#231394) Recent changes to Elasticsearch now makes the GET index_template response include two properties (created_date, modification_date). When updating Ingest Pipelines for Classic Streams, we read this index template using GET and spread the response into our request where we modify the pipeline. This means we pass these new properties as part of the PUT index_template request which Elasticsearch rejects. This PR just removes those two properties from the PUT request. (cherry picked from commit 49b06b23812b287cfe1789994692895f524aa4bb) --- ...anslate_unwired_stream_pipeline_actions.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) 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..1883091ac9fa0 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 @@ -5,7 +5,7 @@ * 2.0. */ -import type { IngestPipeline } from '@elastic/elasticsearch/lib/api/types'; +import type { IndicesIndexTemplate, 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'; @@ -111,21 +111,28 @@ async function createStreamsManagedPipeline({ }, }); + // Remove properties from the GET response that cannot be in the PUT request + // eslint-disable-next-line @typescript-eslint/naming-convention + const { created_date_millis, modified_date_millis, ...safeTemplate } = + indexTemplate.index_template as IndicesIndexTemplate & { + created_date_millis: number; + modified_date_millis: number; + }; + actionsByType.upsert_index_template.push({ type: 'upsert_index_template', request: { name: indexTemplate.name, - ...indexTemplate.index_template, - ignore_missing_component_templates: indexTemplate.index_template - .ignore_missing_component_templates - ? castArray(indexTemplate.index_template.ignore_missing_component_templates) + ...safeTemplate, + ignore_missing_component_templates: safeTemplate.ignore_missing_component_templates + ? castArray(safeTemplate.ignore_missing_component_templates) : [], template: { - ...(indexTemplate.index_template.template ?? {}), + ...(safeTemplate.template ?? {}), settings: { - ...(indexTemplate.index_template.template?.settings ?? {}), + ...(safeTemplate.template?.settings ?? {}), index: { - ...(indexTemplate.index_template.template?.settings?.index ?? {}), + ...(safeTemplate.template?.settings?.index ?? {}), default_pipeline: pipelineName, }, },