-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
inputs
or workflow
is nil when used in sprig expression that has more than 1 parameter (withParam
loop)
#8224
Comments
@aaaaahaaaaa Is it only happening when you are using |
@sarabala1979 Or |
@sarabala1979 I did some more testing and I think I drilled down to a more specific diagnostic that my example above doesn't show. The problem seems to occur when both Examples: WORKS
WORKS
ERROR
This seems really strange but I believe there's really a bug here. |
Hi, bumped into an issue that i think it may relate to this. There's a weird behaviour when using both
As you can see in the case that both Let me know if you find this is related or should i move this to a new issue. |
I don't think you can use "and", you should use "&&". |
Unless this is a custom configuration on argo side Expr does support this Edit: This can easily be tested by something like |
The example workflow is invalid. |
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: my-wf-
spec:
entrypoint: main
arguments:
parameters:
- name: XXX
value: "true"
- name: YYY
value: "false"
templates:
- name: main
inputs:
parameters:
- name: XXX
value: "{{workflow.parameters.XXX}}"
- name: YYY
value: "{{workflow.parameters.YYY}}"
container:
image: argoproj/argosay:v2
command:
- sh
- -c
args:
- |
echo "{{=workflow.parameters.XXX}}" # argo/Mutex/true
echo "{{=workflow.parameters.XXX == 'true' ? workflow.uid : workflow.parameters.XXX }}" # argo/Mutex/d003efcc-7817-4dc0-b435-5c98640ac358
echo "{{=inputs.parameters.YYY == 'false' ? workflow.uid : 'falseee' }}" # argo/Mutex/{{=inputs.parameters.YYY == 'false' ? workflow.uid : 'falseee' }}
echo "{{inputs.parameters.YYY}}" # argo/Mutex/false
echo "{{=inputs.parameters.YYY}}" # argo/Mutex/false
echo "{{=workflow.parameters.XXX == 'true' and inputs.parameters.YYY == 'false' ? 'true' : 'false'}}" # argo/Mutex/{{=workflow.parameters.XXX == 'true' and inputs.parameters.YYY == 'false' ? 'true' : 'false'}}
echo "{{=inputs.parameters.YYY == 'false' and workflow.parameters.XXX == 'true' ? 'true' : 'false'}}" # argo/Mutex/{{=inputs.parameters.YYY == 'false' and workflow.parameters.XXX == 'true' ? 'true' : 'false'}}
echo "{{=inputs.parameters.YYY == 'false' and inputs.parameters.YYY == 'true' ? 'true' : 'false'}}" # argo/Mutex/false
echo "{{=workflow.parameters.XXX == 'true' and workflow.parameters.XXX == 'false' ? 'true' : 'false'}}" # argo/Mutex/false
|
You're correct, I get a different result to you. |
@alexec What about the original issue? |
Could you please re-state the problem? |
@alexec You mean the original post is unclear? |
The gist is, considering the following workflow: ---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: my-template
namespace: argo
spec:
entrypoint: execute
arguments:
parameters:
- name: X
value: xxx
- name: Y
valueFrom:
configMapKeyRef:
name: my-config
key: my-key
templates:
- name: execute
steps:
- - name: other-template
templateRef:
name: other-template
template: execute
withParam: "{{workflow.parameters.Y}}"
arguments:
parameters:
- name: my-param
value: "{{= sprig.replace('what ever', workflow.parameters.X, item.Y) }}" Then the following error is raised:
The problem seems to specifically occur when both worflow.parameters.X and item.Y are used next to each other as parameters of the same function. And again, the following ARE working:
Which is why I believe there's clearly a bug here. |
This comment was marked as resolved.
This comment was marked as resolved.
@alexec Would you confirm that looks like a bug to you? |
We also have this problem @alexec @aaaaahaaaaa steps:
- - name: loop
template: script
arguments:
parameters:
- name: ok
value: "{{ workflow.parameters.some_param }} : {{ item }}"
- name: ok2
value: "{{= asInt(workflow.parameters.iterations) }}"
- name: ok3
value: "{{= asInt(item) }}"
- name: not_ok
value: "{{= asInt(workflow.parameters.some_param) + asInt(item) }}"
withSequence:
count: "5" |
Could you please explain more? |
This should work, but it doesn't. I'm using Argo Workflow v3.3.3 apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: debug-
spec:
arguments:
parameters:
- name: message
value: "hello"
entrypoint: entrypoint
templates:
- name: entrypoint
steps:
- - name: broken
template: speak
arguments:
parameters:
- name: message
value: "{{= workflow.parameters.message + ' ' + item }}"
withSequence:
count: "3"
- name: speak
inputs:
parameters:
- name: message
script:
image: python:alpine
command: ["python"]
source: |-
print("{{ message }}") Expectations
RealityChange But in my use-case I need to do some advanced evaluation using both the workflow param and the loop param e.g |
This might be a long shot, but @aaaaahaaaaa and @rocketspacer, could you try using edit: this issue is limited to hyphenated parameters |
Already tried. Same outcome. |
That's a shame. I thought I was having the same problem but switching to this syntax fixed it. There is definitely something strange about the parser... |
This comment was marked as resolved.
This comment was marked as resolved.
I think the problem is that the workflow contexts (workflow.xxx, inputs.xxx, steps.xxx or tasks.xxx) and the loop context (item) cannot be introduced simultaneously for an expression (starts with {{=). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
2 similar comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@alexec any news on this? I can replicate the issue with a ternary operator apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: debug-
spec:
arguments:
parameters:
- name: default
value: "HELLO"
- name: message
value: |
[
{"a" :1},
{"a" :1,"b": 2}
]
entrypoint: entrypoint
templates:
- name: entrypoint
steps:
- - name: broken
template: speak
arguments:
parameters:
- name: message
value: "{{=item.b != nil ? item.b : workflow.parameters.default}}"
withParam: "{{workflow.parameters.message}}"
- name: speak
inputs:
parameters:
- name: message
script:
image: python:alpine
command: ["python"]
source: |-
print("{{ inputs.parameters.message }}") However, replacing the value with |
This comment was marked as resolved.
This comment was marked as resolved.
+1. This makes it impossible to select a field in a (json) parameter by loop item. E.g.: |
@alexec Any thoughts about this issue from the maintainers team ? One year I am still facing this issue and I don't understand why this issue is marked as closed. |
Would my issue be related to this? I was attempting to map two input parameters to a single output using Helm's I have map:
x:
y: "z" In my workflowtemplate resource, I have an output parameter: outputs:
parameters:
- name: mapped_value # name of output parameter
value: "{{dig `{{inputs.parameters.x}}` `{{inputs.parameters.y}}` `<should-be-z>` .Values.map}}" If I hardcode the parameters passed to the "{{dig x y `<should-be-z>` .Values.map}}"
returns
z However, when I pass the values to the "{{dig `{{inputs.parameters.x}}` `{{inputs.parameters.y}}` `<should-be-z>` .Values.map}}"
returns
<should-be-z> Even when I verify the input parameter values are exactly as I expect them, I cannot get this helm function to work with them. I utilized a helper function to wrap the dig function and verified that the input parameters are correct and matching the hardcoded values. I even attempted to loop through the map via Edit/WorkaroundI achieved my desired functionality by adding a |
+1. I am too facing this issue. I am not able to use the loop context and the workflow context together. |
Checklist
Summary
What happened/what you expected to happen?
With the following context:
withParam
loopargument.parameter.value
sprig
function that as more than 1 parameter (e.g.sprig.replace
)workflow.parameters.paramX
orinputs.parameters.paramX
Then, the following error is thrown:
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.
All the following are however working and are producing the expected values:
Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.
The text was updated successfully, but these errors were encountered: