{"record":{"id":"a06f6eb322160af5","repo":"Tencent/APIJSON","slug":"function","errorCode":null,"errorMessage":"字符 \" + function + \" 不合法！","messagePattern":"字符 \" \\+ function \\+ \" 不合法！","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java","lineNumber":387,"sourceCode":"\t/**反射调用\n\t * @param function 例如get(object,key)，参数只允许引用，不能直接传值\n\t * @param current 不作为第一个参数，就不能远程调用invoke，避免死循环\n\t * @return {@link #invoke(String, M, boolean)}\n\t */\n\t@Override\n\tpublic Object invoke(@NotNull String function, @NotNull M current) throws Exception {\n\t\treturn invoke(function, current, false);\n\t}\n\t/**反射调用\n\t * @param function 例如get(object,key)，参数只允许引用，不能直接传值\n\t * @param current 不作为第一个参数，就不能远程调用invoke，避免死循环\n\t * @param containRaw 包含原始 SQL 片段\n\t * @return {@link #invoke(AbstractFunctionParser, String, M, boolean)}\n\t */\n\t@Override\n\tpublic Object invoke(@NotNull String function, @NotNull M current, boolean containRaw) throws Exception {\n\t\tif (StringUtil.isEmpty(function, true)) {\n\t\t\tthrow new IllegalArgumentException(\"字符 \" + function + \" 不合法！\");\n\t\t}\n\n\t\treturn invoke(this, function, current, containRaw);\n\t}\n\n\t/**反射调用\n\t * @param parser\n\t * @param function 例如get(Map:map,key)，参数只允许引用，不能直接传值\n     * @param current\n     * @return {@link #invoke(AbstractFunctionParser, String, Class[], Object[])}\n\t */\n\t@SuppressWarnings({\"unchecked\", \"rawtypes\"})\n\tpublic static <T, M extends Map<String, Object>, L extends List<Object>> Object invoke(\n\t\t\t@NotNull AbstractFunctionParser<T, M, L> parser, @NotNull String function\n\t\t\t, @NotNull Map<String, Object> current, boolean containRaw) throws Exception {\n        if (ENABLE_REMOTE_FUNCTION == false) {\n            throw new UnsupportedOperationException(\"AbstractFunctionParser.ENABLE_REMOTE_FUNCTION\" +\n                    \" == false 时不支持远程函数！如需支持则设置 AbstractFunctionParser.ENABLE_REMOTE_FUNCTION = true ！\");","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java#L369-L405","documentation":"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.","triggerScenarios":"Calling parser.invoke(\"\", current) or invoke(\"   \", current); typically the function string was built dynamically (string concatenation, config lookup returning empty) and turned out blank.","commonSituations":"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.","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."],"exampleFix":"// before\nObject v = parser.invoke(functionName, current); // functionName may be \"\"\n\n// after\nif (StringUtil.isEmpty(functionName, true) == false) {\n    Object v = parser.invoke(functionName, current);\n}","handlingStrategy":"validation","validationCode":"if (StringUtil.isEmpty(function, true)) {\n    // skip, log, or reject early with context about which field was blank\n}","typeGuard":"public static boolean isNonBlankFunctionExpr(String f) {\n    return StringUtil.isNotEmpty(f, true) && f.indexOf('(') > 0 && f.lastIndexOf(')') == f.length() - 1;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["apijson","remote-function","validation","empty-input"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}