From 31af36b8bde129924053049038b8b3dd0d6cc6e9 Mon Sep 17 00:00:00 2001 From: Romain Dunand Date: Sun, 1 Dec 2019 23:08:37 +0100 Subject: [PATCH] Fix #139 Prevent null values from beeing treaded as objects --- packages/workflow/src/Workflow.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/workflow/src/Workflow.ts b/packages/workflow/src/Workflow.ts index 9efaaa67ec..b48e380edf 100644 --- a/packages/workflow/src/Workflow.ts +++ b/packages/workflow/src/Workflow.ts @@ -865,16 +865,16 @@ export class Workflow { // Execute the expression try { const returnValue = tmpl.tmpl(parameterValue, dataProxy.getDataProxy()); - if (typeof returnValue === 'object' && Object.keys(returnValue).length === 0) { - // When expression is incomplete it returns a Proxy which causes problems. - // Catch it with this code and return a proper error. - throw new Error('Expression is not valid.'); + if (returnValue !== null && typeof returnValue === 'object') { + if (Object.keys(returnValue).length === 0) { + // When expression is incomplete it returns a Proxy which causes problems. + // Catch it with this code and return a proper error. + throw new Error('Expression is not valid.'); + } + if (returnObjectAsString === true) { + return this.convertObjectValueToString(returnValue); + } } - - if (returnObjectAsString === true && typeof returnValue === 'object') { - return this.convertObjectValueToString(returnValue); - } - return returnValue; } catch (e) { throw new Error('Expression is not valid.');