Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid template string error when using variables in workflow command #2678

Closed
tedchang77 opened this issue Nov 25, 2021 · 1 comment · Fixed by #2679
Closed

Invalid template string error when using variables in workflow command #2678

tedchang77 opened this issue Nov 25, 2021 · 1 comment · Fixed by #2679

Comments

@tedchang77
Copy link

Bug

Current Behavior

when running garden run workflow we get an invalid template string error when using variables with helper functions.

Expected behavior

Reproducible example

command: [deploy, "${var.services ? replace(var.services, ' ', ',') : null}"]
results in the following error:
`Error: Invalid template string (${var.services ? replace(var.servi…): Error validating argument 'string' for replace helper function: value must be a string
at resolveTemplateString (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/template-string/template-string.js:0)
at $resolveTemplateStrings (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/template-string/template-string.js:0)
at Object.resolveTemplateStrings (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/util/profiling.js:0)
at /snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/template-string/template-string.js:0
at Array.map ()
at $resolveTemplateStrings (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/template-string/template-string.js:0)
at Object.resolveTemplateStrings (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/util/profiling.js:0)
at RunWorkflowCommand. (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/commands/run/workflow.js:0)
at Generator.next ()
at fulfilled (/snapshot/project/tmp/pkg/cli/node_modules/@garden-io/core/build/src/commands/run/workflow.js:0)
at processTicksAndRejections (internal/process/task_queues.js:97:5)

Error Details:

err:
detail:
value:
message: "\e[31mCould not find key \e[37mservices\e[39m\e[31m\e[39m\e[31m under \e[39m\e[37mvar\e[39m\e[31m.\e[39m"
context: argument 'string' for replace helper function
errorDescription: value must be a string
errorDetails:
- message: value must be a string
path: []
type: string.base
context:
label: value
value: errdetail~value
type: template-string

Workflow deploy-services failed. Total time elapsed: 7.74 Sec.
Done flushing all events and log entries.
Invalid template string (${var.services ? replace(var.servi…): Error validating argument 'string' for replace helper function: value must be a string`

Workaround

Suggested solution(s)

Additional context

https://telushealth.slack.com/archives/C02344N4H39/p1634097347022400?thread_ts=1634097208.022200&cid=C02344N4H39

Your environment

WSL2: Ubuntu 20.04
0.12.30-edge-b705c6f7

@edvald
Copy link
Collaborator

edvald commented Nov 25, 2021

Hmm yes, I can see the issue, I'll look into it. The workaround for this for the moment would be something like ${var.services ? replace(var.services || ' ', ' ', ',') : null}. Notice the added || ' '. It's ugly but works until the fix is done 😬 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants