-
-
Notifications
You must be signed in to change notification settings - Fork 768
Description
SUMMARY
An Orquesta workflow doesn't seem to allow the use of ctx().get(varname,default_val) for attempting to retrieve variables that may not exist from the runtime context.
@nzlosh asked me to open this bug (on the Slack #community channel
STACKSTORM VERSION
st2 3.1.0, on Python 2.7.5
Single box
OS, environment, install method
RHEL 7.6 scripted install
Steps to reproduce the problem
Create and run a workflow using this gist:
https://gist.github.com/markcrobinson/50aeda08afc9b6222983344df9ec7f8c
Expected Results
message1 and message2 contain the contents of the variables published in the tasks
message3 contains the default value ("See ya")
Actual Results
Running the workflow throws a YAQL error for each of the three output statements:
$ st2 run testing.test-ctx-get
.
id: 5e4558b7103007aab0b8bf7b
action.ref: testing.test-ctx-get
parameters: None
status: failed
start_timestamp: Thu, 13 Feb 2020 14:09:59 UTC
end_timestamp: Thu, 13 Feb 2020 14:10:00 UTC
result:
errors:
- expression: <% ctx().get("start_message","Hello world") %>
language: yaql
message: Variable "get" is referenced before assignment.
schema_path: properties.output
spec_path: output[0]
type: context
- expression: <% ctx().get("stop_message","Goodbye") %>
language: yaql
message: Variable "get" is referenced before assignment.
schema_path: properties.output
spec_path: output[1]
type: context
- expression: <% ctx().get("nonexistent","See ya") %>
language: yaql
message: Variable "get" is referenced before assignment.
schema_path: properties.output
spec_path: output[2]
type: context
output: null
isDict(ctx()) returns true
Assigning ctx() into a variable forces it to be a dictionary. @nzlosh game me this workaround:
<% let(x => ctx()) -> $x.get(var, "default") %>