sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

JQ Expressions in Unit Test not consistent with specs standards and examples

Open globalflea opened this issue 3 years ago • 3 comments

I was looking at adding unit test and looked at parser/testdata/workflows/applicationrequest.json with the following DSL:

...
"dataConditions": [
        {
          "condition": "{{ $.applicants[?(@.age >= 18)] }}",
          "transition": {
            "nextState": "StartApplication"
          }
        }, 
...

I noticed that "condition" expression is not in accordance with the specs - the specs says that Jq expression should be within the ${ } rather than {{ }} - is this a mistake or is this intentional (ie. different expression language) ?

Also in the [1.7 versions of the examples in the specs] (https://github.com/serverlessworkflow/specification/blob/v0.7/examples/README.md#Applicant-Request-Decision-Example), it was

...
 "dataConditions": [
            {
              "condition": "${ .applicants | .age >= 18 }",
              "transition": "StartApplication"
            },
...

globalflea avatar Jan 03 '22 07:01 globalflea

I noticed that "condition" expression is not in accordance with the specs - the specs says that Jq expression should be within the ${ } rather than {{ }} - is this a mistake or is this intentional (ie. different expression language) ?

I think I don't understand your question. The question is whether or not the SDK should validate the expression?

ricardozanini avatar Jan 04 '22 13:01 ricardozanini

Actually, I was wondering why the test json specs do not use jq expressions and which expression language is used?

globalflea avatar Jan 04 '22 13:01 globalflea

It's jsonpath if I recall correctly. But the SDK is not parsing the expressions, so won't matter. I think we can add at least a validation to the expressions based on the workflow.expressionLang attribute.

ricardozanini avatar Jan 04 '22 14:01 ricardozanini

Should we close the issue because all jsonpath have been changed to jq:

  • https://github.com/serverlessworkflow/sdk-go/pull/73

lsytj0413 avatar Sep 15 '22 11:09 lsytj0413