Skip to content

Commit

Permalink
Better account for invalid yaml parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Mar 17, 2020
1 parent c18b8d9 commit 60dd245
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => {
type: 'yaml',
value: '',
},
barVar5: {
type: 'yaml',
value: 'testField: test\n invalidSpacing: foo',
},
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 60dd245

Please sign in to comment.