YAQL dict's keys() and items() methods are broken in orquesta workflows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
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 }}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the Orquesta workflow in workflows/wf_orquesta_test9.yaml, using ctx().var1.keys() and the corresponding items() expression described in the issue. Compare the behavior with the YAQL keys and items documentation and the listed list-filter workaround. Done means dictionary keys() and items() can be iterated by the workflow without the type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100