diff --git a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts index c753f25c0cb3ff..7b4e4adc4e4fc2 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts @@ -43,6 +43,10 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { type: 'yaml', value: '', }, + barVar5: { + type: 'yaml', + value: 'testField: test\n invalidSpacing: foo', + }, }, }, ], diff --git a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts index d5bedcf4c1b980..ea048b84afef33 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts @@ -28,8 +28,13 @@ export const storedDatasourceToAgentDatasource = ( (acc, [configName, { type: configType, value: configValue }]) => { if (configValue !== undefined) { if (configType === 'yaml') { - if (configValue.trim()) { - acc[configName] = safeLoad(configValue); + try { + const yamlValue = safeLoad(configValue); + if (yamlValue) { + acc[configName] = yamlValue; + } + } catch (e) { + // Silently swallow parsing error } } else { acc[configName] = configValue;