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

YAQL dict's keys() and items() methods are broken in orquesta workflows #5721

Open
igcherkaev opened this issue Sep 2, 2022 · 3 comments
Open

Comments

@igcherkaev
Copy link

SUMMARY

Two YAQL's methods for dict type are broken: keys() and items().

STACKSTORM VERSION

Paste the output of st2 --version:

$ st2 --version
st2 3.6.0, on Python 3.6.8
OS, environment, install method

Standard installation on Centos 7. The issue confirmed on a test instance by Carlos. His test instance is running st2 3.7.0.

Steps to reproduce the problem

Meta:

---
pack: "playground"
name: "wf_orquesta_test9"
description: "Orquesta test 9"
runner_type: orquesta
enabled: true
entry_point: "workflows/wf_orquesta_test9.yaml"

Orquesta workflow:

---
version: '1.0'
vars:
  - var1:
      key1:
        - item1
        - item2

tasks:
  task1:
    with:
      items: i in <% ctx().var1.keys() %>
    action: core.noop

Expected Results

One iteration of task1 to be executed successfully.
According to YAQL docs: https://yaql.readthedocs.io/en/latest/standard_library.html#keys and https://yaql.readthedocs.io/en/latest/standard_library.html#items - both methods should allow you to iterate over items.
I believe this is some kind of regression bug, as this approach used to work on st2 3.4.1. Some time after that it got broken.

Actual Results

id: 63121fb20fd8433f83f4cf8b
action.ref: playground.wf_orquesta_test9
parameters: None
status: failed (1s elapsed)
start_timestamp: Fri, 02 Sep 2022 15:22:26 UTC
end_timestamp: Fri, 02 Sep 2022 15:22:27 UTC
log: 
  - status: requested
    timestamp: '2022-09-02T15:22:26.964000Z'
  - status: scheduled
    timestamp: '2022-09-02T15:22:27.121000Z'
  - status: running
    timestamp: '2022-09-02T15:22:27.175000Z'
  - status: failed
    timestamp: '2022-09-02T15:22:27.353000Z'
result: 
  errors:
  - message: 'TypeError: The value of "<% ctx().var1.keys() %>" is not type of list.'
    route: 0
    task_id: task1
    type: error
  output: null

P.S. For those who run into the same issue, there is a workaround:

  task1:
    with:
      items: i in {{ ctx().var1.keys() | list }}
@igcherkaev
Copy link
Author

There's an existing issue that's been already reported: StackStorm/orquesta#247
Let me know if you'd like to close this one or that one to avoid duplicates.

@igcherkaev
Copy link
Author

Another report for the same issue: #5547

@igcherkaev
Copy link
Author

@cognifloyd suggested using this and it seems to be working, in case other YAQL expressions are broken:

tasks:
  task1:
    with:
      items: i in <% ctx().var1.keys().toList() %>
    action: core.noop

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

No branches or pull requests

1 participant