conductor-oss/conductor · error · TerminateWorkflowException

Error evaluating the script `%s` at line %d

Error message

Error evaluating the script `%s` at line %d

What it means

Raised by handlePolyglotException when a PolyglotException has a non-null SourceSection. This is the normal case for a guest-code runtime/syntax error: GraalVM can report the offending line. The message, with line number, is wrapped in a TerminateWorkflowException and terminates the workflow.

Source

Thrown at core/src/main/java/com/netflix/conductor/core/events/ScriptEvaluator.java:387

                                maxExecutionTimeSeconds.getSeconds()));
            } catch (ExecutionException ee) {
                handlePolyglotException(ee);
                return null;
            } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
                throw new NonTransientException("Script execution interrupted: " + ie.getMessage());
            }
        }
    }

    private static void handlePolyglotException(ExecutionException ee) {
        if (ee.getCause() instanceof PolyglotException pe) {
            SourceSection sourceSection = pe.getSourceLocation();
            if (sourceSection == null) {
                throw new TerminateWorkflowException(
                        "Error evaluating the script `" + pe.getMessage() + "`");
            } else {
                throw new TerminateWorkflowException(
                        "Error evaluating the script `"
                                + pe.getMessage()
                                + "` at line "
                                + sourceSection.getStartLine());
            }
        }
        throw new TerminateWorkflowException("Error evaluating the script " + ee.getMessage());
    }

    private static Object getObject(Value value) {
        if (value.isNull()) return null;
        if (value.isBoolean()) return value.asBoolean();
        if (value.isString()) return value.asString();
        if (value.isNumber()) {
            if (value.fitsInInt()) return value.asInt();
            if (value.fitsInLong()) return value.asLong();
            if (value.fitsInDouble()) return value.asDouble();
        }

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Use the reported line number to jump to the failing expression in the script.
  2. Validate the script in a local GraalJS/Node REPL with the same input before deploying.
  3. Add input guards (optional chaining, typeof checks) so missing fields do not throw.
  4. For expression tasks, prefer simple `$.` accessors over imperative logic.

Example fix

// before
$.user.address.city  // throws if address is null

// after
($.user.address && $.user.address.city) || 'unknown'
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate JS parses with a throwaway GraalVM Source before deployment.
try {
    Source source = Source.create("js", script);
    // optionally eval against {} to surface runtime ReferenceErrors early
} catch (org.graalvm.polyglot.PolyglotException pe) {
    throw new IllegalArgumentException("Invalid script at line " + pe.getSourceLocation().getStartLine(), pe);
}

Try / catch

try {
    Object result = ScriptEvaluator.eval(script, input);
} catch (TerminateWorkflowException e) {
    LOGGER.error("Script error: {}", e.getMessage()); // contains line number
    throw e;
}

Prevention

When it happens

Trigger: A JavaScript expression throws a guest-level error that GraalVM attributes to a source location: TypeError, ReferenceError, SyntaxError, RangeError, or an explicit `throw` inside the script.

Common situations: Script references an undefined variable (e.g. typo in a `$.*` path), calls a non-function, indexes into null, or has a syntax error in a workflow's inline JS task.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/a60e8b1eacc690fb. Report an issue: GitHub.