argo-workflows: `inputs` or `workflow` is nil when used in sprig expression that has more than 1 parameter (`withParam` loop)
Checklist
- Double-checked my configuration.
- Tested using the latest version.
- Used the Emissary executor.
Summary
What happened/what you expected to happen?
With the following context:
- within a
withParam
loop - in
argument.parameter.value
- using a
sprig
function that as more than 1 parameter (e.g.sprig.replace
) - referencing
workflow.parameters.paramX
orinputs.parameters.paramX
Then, the following error is thrown:
Warning WorkflowFailed 3s workflow-controller failed to evaluate expression: cannot fetch parameters from <nil> (1:23)
| sprig.replace(inputs.parameters.paramX, 'YYY', 'Replace XXX')
| ......................^
If the expression uses a sprig function with 1 parameter, then the error doesn’t occur.
What version are you running?
3.3.0
Diagnostics
Paste the smallest workflow that reproduces the bug. We must be able to run the workflow.
---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: my-template
namespace: argo
spec:
entrypoint: execute
arguments:
parameters:
- name: paramX
value: XXX
- name: paramY
valueFrom:
configMapKeyRef:
name: my-config
key: my-key
templates:
- name: execute
steps:
- - name: other-template
templateRef:
name: other-template
template: execute
withParam: "{{workflow.parameters.paramY}}"
arguments:
parameters:
- name: my-param
value: "{{= sprig.replace(workflow.parameters.paramX, "YYY", "Replace XXX" }}"
All the following are however working and are producing the expected values:
parameters:
- name: my-param
value: "{{ workflow.parameters.paramX }}"
parameters:
- name: my-param
value: "{{= workflow.parameters.paramX }}"
parameters:
- name: my-param
value: "{{= sprig.trim(workflow.parameters.paramX) }}"
Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 9
- Comments: 34 (13 by maintainers)
This issue has been closed due to inactivity. Feel free to re-open if you still encounter this issue.
+1. I am too facing this issue. I am not able to use the loop context and the workflow context together.
+1. This makes it impossible to select a field in a (json) parameter by loop item. E.g.:
{{=sprig.fromJson(input.parameters.somejsonparam)[item]}}
up
You’re correct,
and
works. I learnt something.I get a different result to you.