Skip to content

Commit

Permalink
fix(yaml): allow filtering of invalid multidoc (#31963)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored Oct 15, 2024
1 parent fbc3ba8 commit b923c40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/util/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b923c40

Please sign in to comment.