diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts index 0d895c22179c7..0be8cdce3560b 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts @@ -155,6 +155,10 @@ export const hydrateMonitorFields = async ({ { preserve_namespace?: boolean } >; + const inlineSource = (normalizedMonitor as BrowserSensitiveSimpleFields)?.[ + ConfigKey.SOURCE_INLINE + ] as string | undefined; + return { ...normalizedMonitor, [ConfigKey.MONITOR_QUERY_ID]: normalizedMonitor[ConfigKey.CUSTOM_HEARTBEAT_ID] || newMonitorId, @@ -162,14 +166,8 @@ export const hydrateMonitorFields = async ({ [ConfigKey.NAMESPACE]: preserveNamespace ? normalizedMonitor[ConfigKey.NAMESPACE] : getMonitorNamespace(server, request, normalizedMonitor[ConfigKey.NAMESPACE]), - [ConfigKey.SOURCE_PROJECT_CONTENT]: !!(normalizedMonitor as BrowserSensitiveSimpleFields)?.[ - ConfigKey.SOURCE_INLINE - ] - ? await inlineToProjectZip( - (normalizedMonitor as BrowserSensitiveSimpleFields)?.[ConfigKey.SOURCE_INLINE] as string, - newMonitorId, - server.logger - ) + [ConfigKey.SOURCE_PROJECT_CONTENT]: !!inlineSource + ? await inlineToProjectZip(inlineSource, newMonitorId, server.logger) : '', }; };