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

Validation errors in tasks with SWITCH type containing JS expressions after upgrading to 3.16.0 #101

Closed
SchepiLove opened this issue Mar 6, 2024 · 1 comment

Comments

@SchepiLove
Copy link

Describe the bug
When loading workflow definition with SWITCH type tasks with JS expressions, I get validation error.
Also, when loading workflow definition in task there are no inputParameters, which can lead to erroneous execution of eval()
Object returnValue = ScriptEvaluator.eval(expression, inputParameters);

Details
Conductor version: 3.16.0
Persistence implementation: Redis
Queue implementation: Dynoqueues
Lock: Redis
Task definition: SWITCH

To Reproduce
Сreate a workflow definition with a SWITCH type task with an expression:

function check(){
    var inputResult = $.inputResult;
    var result = "OK";
    if (!inputResult || !inputResult.serviceResult || inputResult.serviceResult.resultType === "ERROR") {
        result = "ERROR";
    }
    if (inputResult.serviceResult.resultCode === "-1001") {
        result = "NOT_FOUND";
}
    return result;
}

check()

Get the logs:
ConstraintViolationImpl{interpolatedMessage='Expression is not well formatted: TypeError: Cannot read property "resultCode" from undefined in at line number 10, taskType: SWITCH taskName SWITCH_TASK', propertyPath=tasks[12], rootBeanClass=class com.netflix.conductor.common.metadata.workflow.WorkflowDef, messageTemplate='Expression is not well formatted: TypeError: Cannot read property "resultCode" from undefined in at line number 10, taskType: SWITCH taskName SWITCH_TASK'}

Expected behavior
Before the upgrade, these tasks with expressions worked properly and eval() returned the expected result

Additional context
changes in validation with version upgrade:
Netflix/conductor#3805

@SchepiLove
Copy link
Author

Everything was solved by passing to the input only those fields that were required in this expression. But filtering still had to be moved to jsonPath, because validation did not pass on the expression
"expression": "Java.from($.statuses).filter(function (el) { return el.toLowerCase() !== 'ok' }).length > 0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant