Skip to content
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

sprig expression that works in 3.3.9 doesn't work in 3.4.0 #9625

Closed
2 of 3 tasks
tooptoop4 opened this issue Sep 20, 2022 · 6 comments · Fixed by #9661
Closed
2 of 3 tasks

sprig expression that works in 3.3.9 doesn't work in 3.4.0 #9625

tooptoop4 opened this issue Sep 20, 2022 · 6 comments · Fixed by #9661
Assignees
Labels
area/controller Controller issues, panics area/templating Templating with `{{...}}` P1 High priority. All bugs with >=5 thumbs up that aren’t P0, plus: Any other bugs deemed high priority type/bug type/regression Regression from previous behavior (a specific type of bug)

Comments

@tooptoop4
Copy link
Contributor

tooptoop4 commented Sep 20, 2022

Pre-requisites

  • I have double-checked my configuration
  • I can confirm the issues exists when I tested with :latest
  • I'd like to contribute the fix myself (see contributing guide)

What happened/what you expected to happen?

a param to my workflow is a payload like the json in these 12 lines:
https://github.com/LeidosLabs/holeshot/blob/b3aa04a84059e3a4c07d42ff9a46cc37f443eb3d/ingest-service/src/test/resources/sample-notification.json#L1-L12

my expression below worked fine in 3.3.9 but in 3.4.0 gives error

                workflowMetadata:
                  labelsFrom:
                    s3-folder:
                      expression: "{{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}"
Error: failed to evaluate label "s3-folder" expression "{{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}": a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Bracket("{")) (1:2) | {{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }} | .^

Version

3.4.0

Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.

n/a

Logs from the workflow controller

kubectl logs -n argo deploy/workflow-controller | grep ${workflow}

time="2022-09-20T00:57:22.742Z" level=info msg="Processing workflow" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Updated phase  -> Error" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Updated message  -> failed to evaluate label \"s3-folder\" expression \"{{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}\": a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Bracket(\"{\")) (1:2)\n | {{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}\n | .^" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Marking workflow completed" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Marking workflow as pending archiving" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=error msg="Unable to set ExecWorkflow" error="failed to evaluate label \"s3-folder\" expression \"{{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}\": a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Bracket(\"{\")) (1:2)\n | {{= sprig.quote(sprig.regexReplaceAll('^[-_.]*',sprig.regexReplaceAll('[-_.]*$',sprig.substr(0,63,sprig.regexReplaceAll('[^-A-Za-z0-9_.]',sprig.regexReplaceAll('/([^/]*)$',sprig.regexFind('landing/([^,]+),', workflow.parameters.message),''),'')),''),'')) }}\n | .^" namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Checking daemoned children of " namespace=auth workflow=redacted
time="2022-09-20T00:57:22.749Z" level=info msg="Workflow to be dehydrated" Workflow Size=44708

Logs from in your workflow's wait container

kubectl logs -c wait -l workflows.argoproj.io/workflow=${workflow},workflow.argoproj.io/phase!=Succeeded

@juliev0 juliev0 self-assigned this Sep 20, 2022
@juliev0 juliev0 added the type/regression Regression from previous behavior (a specific type of bug) label Sep 20, 2022
@juliev0
Copy link
Contributor

juliev0 commented Sep 21, 2022

@tooptoop4 since your regex example is finding some text like "landing/" I thought I might see that in your example payload, but it isn't in there, right? Do you by chance have a payload that better matches the nested regex expressions?

@tooptoop4
Copy link
Contributor Author

@juliev0 in the json payload u can change po_235248_pan_0000000.ntf to landing/mysch/mytbl/po_235248_pan_0000000.ntf

@juliev0
Copy link
Contributor

juliev0 commented Sep 21, 2022

@juliev0 in the json payload u can change po_235248_pan_0000000.ntf to landing/mysch/mytbl/po_235248_pan_0000000.ntf

okay, thanks!

@juliev0
Copy link
Contributor

juliev0 commented Sep 21, 2022

I can see that the commit you referenced does in fact break this. And that's because in operator.go, substituteGlobalVariables() is now being called after updateWorkflowMetadata(). I need to do more investigation to figure out the right order for these functions to be called. I believe in that commit that the order got changed, but for a different reason.

@sarabala1979 sarabala1979 added area/controller Controller issues, panics P1 High priority. All bugs with >=5 thumbs up that aren’t P0, plus: Any other bugs deemed high priority labels Sep 23, 2022
@agilgur5 agilgur5 added the area/templating Templating with `{{...}}` label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controller Controller issues, panics area/templating Templating with `{{...}}` P1 High priority. All bugs with >=5 thumbs up that aren’t P0, plus: Any other bugs deemed high priority type/bug type/regression Regression from previous behavior (a specific type of bug)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants