Skip to content

Commit

Permalink
fix(template-strings): do not apply helper functions on unresolved st…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
shumailxyz committed Jun 21, 2023
1 parent 08c1051 commit 5ab82e3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/src/template-string/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 5ab82e3

Please sign in to comment.