Merge pull request #8226 from backstage/blam/relax-log-lines
Fixing superfluous log lines by changing the check to see if it's a template string for Scaffolder v3 templates
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Fix bug where there was error log lines written when failing to `JSON.parse` things that were not `JSON` values.
|
||||
+25
@@ -270,6 +270,31 @@ describe('DefaultWorkflowRunner', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should not try and parse something that is not parsable', async () => {
|
||||
jest.spyOn(logger, 'error');
|
||||
const task = createMockTaskWithSpec({
|
||||
apiVersion: 'scaffolder.backstage.io/v1beta3',
|
||||
steps: [
|
||||
{
|
||||
id: 'test',
|
||||
name: 'name',
|
||||
action: 'jest-mock-action',
|
||||
input: {
|
||||
foo: 'bob',
|
||||
},
|
||||
},
|
||||
],
|
||||
output: {},
|
||||
parameters: {
|
||||
input: 'BACKSTAGE',
|
||||
},
|
||||
});
|
||||
|
||||
await runner.execute(task);
|
||||
|
||||
expect(logger.error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should keep the original types for the input and not parse things that arent meant to be parsed', async () => {
|
||||
const task = createMockTaskWithSpec({
|
||||
apiVersion: 'scaffolder.backstage.io/v1beta3',
|
||||
@@ -114,9 +114,10 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
|
||||
private isSingleTemplateString(input: string) {
|
||||
const { parser, nodes } = require('nunjucks');
|
||||
const parsed = parser.parse(input, {}, this.nunjucksOptions);
|
||||
|
||||
return (
|
||||
parsed.children.length === 1 &&
|
||||
!(parsed.children[0] instanceof nodes.TemplateData)
|
||||
!(parsed.children[0]?.children?.[0] instanceof nodes.TemplateData)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user