{"record":{"id":"a4dbb15fd549e6ee","repo":"conductor-oss/conductor","slug":"expression-is-not-well-formatted-s","errorCode":null,"errorMessage":"Expression is not well formatted: %s","messagePattern":"Expression is not well formatted: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"core/src/main/java/com/netflix/conductor/validations/WorkflowTaskTypeConstraint.java","lineNumber":197,"sourceCode":"                                    ee.getMessage() + \", taskType: DECISION taskName %s\",\n                                    workflowTask.getName());\n                    context.buildConstraintViolationWithTemplate(message).addConstraintViolation();\n                    valid = false;\n                }\n            }\n\n            return valid;\n        }\n\n        private void validateScriptExpression(\n                String expression, Map<String, Object> inputParameters) {\n            try {\n                // Syntax check only: at registration time inputParameters still holds unresolved\n                // ${...} placeholders, so evaluating the expression would throw ReferenceError\n                // for any runtime-bound variable and reject valid definitions (issue #1311).\n                ScriptEvaluator.validateScriptSyntax(expression);\n            } catch (Exception e) {\n                throw new IllegalArgumentException(\n                        String.format(\"Expression is not well formatted: %s\", e.getMessage()));\n            }\n        }\n\n        private boolean isSwitchTaskValid(\n                WorkflowTask workflowTask, ConstraintValidatorContext context) {\n            boolean valid = true;\n            if (workflowTask.getEvaluatorType() == null) {\n                String message =\n                        String.format(\n                                PARAM_REQUIRED_STRING_FORMAT,\n                                \"evaluatorType\",\n                                TaskType.SWITCH,\n                                workflowTask.getName());\n                context.buildConstraintViolationWithTemplate(message).addConstraintViolation();\n                valid = false;\n            } else if (workflowTask.getExpression() == null) {\n                String message =","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/core/src/main/java/com/netflix/conductor/validations/WorkflowTaskTypeConstraint.java#L179-L215","documentation":"Thrown during workflow definition validation (WorkflowTaskTypeConstraint) when a DECISION task's caseExpression or a SWITCH task's expression (with evaluatorType 'javascript') fails a syntax-only check by ScriptEvaluator.validateScriptSyntax (GraalVM Context.parse). It signals a malformed JavaScript expression that cannot even be parsed. Surfaced as a constraint violation at registration/update time (HTTP 400).","triggerScenarios":"Registering or updating a workflow whose DECISION.caseExpression or SWITCH.expression (evaluatorType=javascript) contains a JavaScript syntax error (unbalanced parens, stray token, unterminated string). validateScriptSyntax rethrows only PolyglotException where isSyntaxError() is true.","commonSituations":"Hand-writing JS expressions like '$.amount >' (incomplete) or '${ if($.x) } ' (invalid placeholder splice); copy-paste introducing a stray character; expecting a different expression dialect; mixing ${} interpolation with raw JS that breaks the parsed form.","solutions":["Test the expression in a JS parser/node REPL with placeholders substituted by sample values.","Ensure parentheses/braces are balanced and strings terminated.","For SWITCH tasks confirm evaluatorType is 'javascript' and expression is pure JS (minus ${} placeholders which are resolved before evaluation at runtime).","Note: only syntax is checked at registration; runtime ReferenceErrors from unbound variables are NOT caught here (issue #1311)."],"exampleFix":"// before - DECISION task with broken expression\n{\n  \"name\": \"check\",\n  \"taskReferenceName\": \"check_ref\",\n  \"type\": \"DECISION\",\n  \"caseExpression\": \"$.amount >\"\n}\n\n// after - complete, valid boolean expression\n{\n  \"name\": \"check\",\n  \"taskReferenceName\": \"check_ref\",\n  \"type\": \"DECISION\",\n  \"caseExpression\": \"$.amount > 100\"\n}","handlingStrategy":"validation","validationCode":"// Pre-validate the JS expression syntax before registration\ntry {\n    com.netflix.conductor.core.events.ScriptEvaluator.validateScriptSyntax(expression);\n} catch (IllegalArgumentException e) {\n    // fix the expression\n}","typeGuard":null,"tryCatchPattern":"try {\n    metadataService.registerWorkflowDef(def);\n} catch (ValidationException e) {\n    // e contains 'Expression is not well formatted' for bad JS\n}","preventionTips":["Test JS expressions in a JS parser before registering","Balance parentheses/braces and terminate strings","Remember only syntax is checked, not runtime variable resolution"],"tags":["validation","workflow-def","javascript","expression","conductor","java"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}