From 5ab82e3c22e3e67090bcf2235e3e5eb17bcb359e Mon Sep 17 00:00:00 2001 From: Shumail Mohyuddin Date: Wed, 21 Jun 2023 22:33:39 +0200 Subject: [PATCH] fix(template-strings): do not apply helper functions on unresolved string --- core/src/template-string/functions.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/template-string/functions.ts b/core/src/template-string/functions.ts index 3fbd247fff3..5c3aa7bdd8b 100644 --- a/core/src/template-string/functions.ts +++ b/core/src/template-string/functions.ts @@ -16,6 +16,7 @@ import { validateSchema } from "../config/validation" import { load, loadAll } from "js-yaml" import { safeDumpYaml } from "../util/serialization" import indentString from "indent-string" +import { maybeTemplateString } from "./template-string" interface ExampleArgument { input: any[] @@ -508,6 +509,19 @@ export function callHelperFunction({ context: `argument '${argName}' for ${functionName} helper function`, ErrorClass: TemplateStringError, }) + + // do not apply helper function for an unresolved template string + if (maybeTemplateString(value)) { + const _error = new TemplateStringError(`Function '${functionName}' cannot be applied on unresolved string`, { + functionName, + text, + }) + if (allowPartial) { + return { resolved: "${" + text + "}" } + } else { + return { _error } + } + } } catch (_error) { if (allowPartial) { return { resolved: text }