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

Orquesta workflow ctx().get() throws a YAQL error #4866

Closed
markcrobinson opened this issue Feb 13, 2020 · 1 comment · Fixed by StackStorm/orquesta#196
Closed

Orquesta workflow ctx().get() throws a YAQL error #4866

markcrobinson opened this issue Feb 13, 2020 · 1 comment · Fixed by StackStorm/orquesta#196

Comments

@markcrobinson
Copy link

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") %>
@m4dcoder
Copy link
Contributor

Looks like orquesta is confusing the dict methods as variables during validation.

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

Successfully merging a pull request may close this issue.

3 participants