Tencent/APIJSON · error · IllegalArgumentException
字符 " + function + " 不合法!
Error message
字符 " + function + " 不合法!
What it means
AbstractFunctionParser.invoke(function, current) validates that the remote-function expression is a non-blank string before parsing it. An empty, null-equivalent, or whitespace-only function string is rejected immediately with IllegalArgumentException because it cannot possibly match the required function(key0,key1,...) grammar.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java:387
/**反射调用
* @param function 例如get(object,key),参数只允许引用,不能直接传值
* @param current 不作为第一个参数,就不能远程调用invoke,避免死循环
* @return {@link #invoke(String, M, boolean)}
*/
@Override
public Object invoke(@NotNull String function, @NotNull M current) throws Exception {
return invoke(function, current, false);
}
/**反射调用
* @param function 例如get(object,key),参数只允许引用,不能直接传值
* @param current 不作为第一个参数,就不能远程调用invoke,避免死循环
* @param containRaw 包含原始 SQL 片段
* @return {@link #invoke(AbstractFunctionParser, String, M, boolean)}
*/
@Override
public Object invoke(@NotNull String function, @NotNull M current, boolean containRaw) throws Exception {
if (StringUtil.isEmpty(function, true)) {
throw new IllegalArgumentException("字符 " + function + " 不合法!");
}
return invoke(this, function, current, containRaw);
}
/**反射调用
* @param parser
* @param function 例如get(Map:map,key),参数只允许引用,不能直接传值
* @param current
* @return {@link #invoke(AbstractFunctionParser, String, Class[], Object[])}
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T, M extends Map<String, Object>, L extends List<Object>> Object invoke(
@NotNull AbstractFunctionParser<T, M, L> parser, @NotNull String function
, @NotNull Map<String, Object> current, boolean containRaw) throws Exception {
if (ENABLE_REMOTE_FUNCTION == false) {
throw new UnsupportedOperationException("AbstractFunctionParser.ENABLE_REMOTE_FUNCTION" +
" == false 时不支持远程函数!如需支持则设置 AbstractFunctionParser.ENABLE_REMOTE_FUNCTION = true !");View on GitHub (pinned to 5284052872)
Solutions
- Check StringUtil.isEmpty(function, true) before invoking and skip or default.
- Fix the source of the function string (config value, DB column, request field) so it is a valid expression.
- Log the offending request payload to find which field carried the blank function.
Example fix
// before
Object v = parser.invoke(functionName, current); // functionName may be ""
// after
if (StringUtil.isEmpty(functionName, true) == false) {
Object v = parser.invoke(functionName, current);
} Defensive patterns
Strategy: validation
Validate before calling
if (StringUtil.isEmpty(function, true)) {
// skip, log, or reject early with context about which field was blank
} Type guard
public static boolean isNonBlankFunctionExpr(String f) {
return StringUtil.isNotEmpty(f, true) && f.indexOf('(') > 0 && f.lastIndexOf(')') == f.length() - 1;
} Prevention
- Never build function strings by raw concatenation of user input.
- Default config-driven function names to a known-valid constant, not empty string.
- Unit-test request builders to assert function expressions are non-blank and well-formed.
When it happens
Trigger: Calling parser.invoke("", current) or invoke(" ", current); typically the function string was built dynamically (string concatenation, config lookup returning empty) and turned out blank.
Common situations: Function name read from a config/DB column that is NULL/empty; template interpolation that produced an empty string; request JSON has "@column" or similar containing an empty function expression.
Related errors
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
- {}/{}:value 中 value 必须为函数String!
- Cannot convert value of type " + value.getClass().getName()
- AbstractFunctionParser.ENABLE_REMOTE_FUNCTION == false 时不支持远
- 不允许调用远程函数 " + fb.getMethod() + " !
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/a06f6eb322160af5.
Report an issue: GitHub.