ssssssss-team/spider-flow · error · ScriptException
_eval必须要有一个参数
Error message
_eval必须要有一个参数
What it means
Guard inside ScriptManager.eval: when the expression engine calls the built-in _eval function, exactly one argument (the script text to evaluate) is required. The error fires when args is null or its length differs from 1, i.e. a spider-flow expression invoked _eval with zero or multiple arguments, so the Nashorn script cannot be built.
Solutions
- Pass exactly one argument to _eval in the expression, e.g. _eval('return 1+1').
- If dynamic argument counts are needed, build the script string first and pass it as a single argument.
- Check the flow variable feeding the argument — a missing variable can collapse the argument list to zero arguments.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at spider-flow-core/src/main/java/org/spiderflow/core/script/ScriptManager.java:102 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ssssssss-team/spider-flow@c799cca99c (2026-09-08).
Data as JSON: /api/errors/1b37c16d9e2c8d7c.
Report an issue: GitHub.
Appendix: source
Thrown at spider-flow-core/src/main/java/org/spiderflow/core/script/ScriptManager.java:102
}
public static boolean containsFunction(String functionName){
try {
lock.readLock().lock();
return functions.contains(functionName);
} finally {
lock.readLock().unlock();
}
}
public static void validScript(String functionName,String parameters,String script) throws Exception {
new ScriptEngineManager().getEngineByName("nashorn").eval(concatScript(functionName,parameters,script));
}
public static Object eval(ExpressionTemplateContext context, String functionName, Object ... args) throws ScriptException, NoSuchMethodException {
if("_eval".equals(functionName)){
if(args == null || args.length != 1){
throw new ScriptException("_eval必须要有一个参数");
}else{
return ExpressionTemplate.create(args[0].toString()).render(context);
}
}
if(scriptEngine == null){
throw new NoSuchMethodException(functionName);
}
try{
lock.readLock().lock();
return convertObject(((Invocable) scriptEngine).invokeFunction(functionName, args));
} finally{
lock.readLock().unlock();
}
}
private static Object convertObject(Object object){
if(object instanceof ScriptObjectMirror){
ScriptObjectMirror mirror = (ScriptObjectMirror) object;View on GitHub (pinned to c799cca99c)