New JSON attributes are now considered warnings in testing workflows (#2432)

This commit is contained in:
Omar Ajoue 2021-11-12 14:28:49 +01:00 committed by GitHub
parent 15e64d1bc4
commit 357178d83b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -817,10 +817,22 @@ export class ExecuteBatch extends Command {
const changes = diff(JSON.parse(contents), data, { keysOnly: true }); const changes = diff(JSON.parse(contents), data, { keysOnly: true });
if (changes !== undefined) { if (changes !== undefined) {
// If we had only additions with no removals
// Then we treat as a warning and not an error.
// To find this, we convert the object to JSON
// and search for the `__deleted` string
const changesJson = JSON.stringify(changes);
if (changesJson.includes('__deleted')) {
// we have structural changes. Report them. // we have structural changes. Report them.
executionResult.error = `Workflow may contain breaking changes`; executionResult.error = 'Workflow may contain breaking changes';
executionResult.changes = changes; executionResult.changes = changes;
executionResult.executionStatus = 'error'; executionResult.executionStatus = 'error';
} else {
executionResult.error =
'Workflow contains new data that previously did not exist.';
executionResult.changes = changes;
executionResult.executionStatus = 'warning';
}
} else { } else {
executionResult.executionStatus = 'success'; executionResult.executionStatus = 'success';
} }