Rendering Object from Jinja within ActionChain
Nobody has claimed this yet.
- 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
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
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