Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading