StackStorm / StackStorm/st2

Rendering Object from Jinja within ActionChain

Open
#4,096 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale status:to be verified workflows: action chain
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Attempting to do this:

- name: "lookup_netbox_role"
    ref: "netbox.ipam_get_roles"
    publish:
      role_my_block: "{{ lookup_netbox_role.result.raw.results | selectattr('slug', 'equalto', 'platform_my_block') | list | first }}"
      role_my_other_block: "{{ lookup_netbox_role.result.raw.results | selectattr('slug', 'equalto', 'platform_my_other_block') | list | first }}"
    on-success: "assign_superblock"

The Jinja2 expression filters down the result of my action to something like this: {'id': 10, 'name': 'Platform_My_Block', 'weight': 1000, 'slug': 'platform_my_block'} however this is published as a string.

Further into my chain I attempt to access the id with {{ role_my_block.id }} and I'm told "Failed to run task \"assign_superblock\". Parameter rendering failed.. Failed rendering value for action parameter \"role\" in task \"assign_superblock\" (template string={{ role_my_block.id }}): 'unicode object' has no attribute 'id'"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ActionChain YAML example and trace how the Jinja expression in the publish section is rendered. Reproduce the chain where the filtered object becomes a string, then verify that a later expression such as {{ role_my_block.id }} can access the published object's id without the rendering failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.