Skip to content
Snippets Groups Projects
Unverified Commit b923c40e authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix(yaml): allow filtering of invalid multidoc (#31963)

parent fbc3ba8d
No related branches found
No related tags found
No related merge requests found
......@@ -63,19 +63,19 @@ export function parseYaml<ResT = unknown>(
const results: ResT[] = [];
for (const rawDocument of rawDocuments) {
const document = rawDocument.toJS({ maxAliasCount: 10000 });
const errors = rawDocument.errors;
// handle YAML parse errors
if (errors?.length) {
const error = new AggregateError(errors, 'Failed to parse YAML file');
if (options?.failureBehaviour === 'filter') {
logger.debug({ error, document }, 'Failed to parse YAML');
logger.debug(`Failed to parse YAML file: ${error.message}`);
continue;
}
throw error;
}
const document = rawDocument.toJS({ maxAliasCount: 10000 });
// skip schema validation if no schema is provided
if (!schema) {
results.push(document as ResT);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment