diff --git a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts index 662b12494cbbc..f4b997f80a82f 100644 --- a/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts +++ b/x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts @@ -7,6 +7,8 @@ import type { estypes } from '@elastic/elasticsearch'; +import type { IngestPipeline } from '@elastic/elasticsearch/lib/api/types'; + import type { ASSETS_SAVED_OBJECT_TYPE, agentAssetTypes, @@ -799,6 +801,15 @@ export interface IndexTemplate { modified_date_millis?: number; } +export interface IngestPipelineWithDateFields extends IngestPipeline { + // These properties are returned on ES read operations and + // not allowed to be set on ES write operations + created_date?: number; + created_date_millis?: number; + modified_date?: number; + modified_date_millis?: number; +} + export interface ESAssetMetadata { package?: { name: string; diff --git a/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.test.ts b/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.test.ts index f4272b6343d1d..2be51b46f7e89 100644 --- a/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.test.ts +++ b/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.test.ts @@ -702,6 +702,11 @@ describe('custom assets', () => { }, ], version: 1, + description: 'description pipeline', + created_date: '2024-01-01T12:00:00.000Z', + created_date_millis: 1704110400000, + modified_date: '2025-01-01T12:00:00.000Z', + modified_date_millis: 1735732800000, }, type: 'ingest_pipeline', }, @@ -721,6 +726,7 @@ describe('custom assets', () => { }, ], version: 1, + description: 'description pipeline', }, expect.anything() ); diff --git a/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts b/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts index d1bc71da6bb86..2d0e0086212e0 100644 --- a/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts +++ b/x-pack/platform/plugins/shared/fleet/server/tasks/sync_integrations/custom_assets.ts @@ -18,6 +18,8 @@ import { retryTransientEsErrors } from '../../services/epm/elasticsearch/retry'; import { packagePolicyService } from '../../services'; import { SO_SEARCH_LIMIT } from '../../constants'; +import type { IngestPipelineWithDateFields } from '../../../common/types'; + import type { CustomAssetsData, IntegrationsData, SyncIntegrationsData } from './model'; const DELETED_ASSET_TTL = 7 * 24 * 60 * 60 * 1000; // 7 days @@ -297,12 +299,21 @@ async function updateIngestPipeline( if (shouldUpdatePipeline) { logger.debug(`Updating ingest pipeline: ${customAsset.name}`); + + // Remove system-managed properties (dates) that cannot be set during create/update of ingest pipelines + const { + created_date: createdDate, + created_date_millis: createdDateMillis, + modified_date: modifiedDate, + modified_date_millis: modifiedDateMillis, + ...updatedIngestPipeline + } = customAsset.pipeline as IngestPipelineWithDateFields; return retryTransientEsErrors( () => esClient.ingest.putPipeline( { id: customAsset.name, - ...customAsset.pipeline, + ...updatedIngestPipeline, }, { signal: abortController.signal,