{"record":{"id":"505acbdb5d166010","repo":"Tencent/APIJSON","slug":"fb-getmethod","errorCode":null,"errorMessage":"不允许调用远程函数 \" + fb.getMethod() + \" !","messagePattern":"不允许调用远程函数 \" \\+ fb\\.getMethod\\(\\) \\+ \" !","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java","lineNumber":412,"sourceCode":"\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 ！\");\n        }\n\n\t\tFunctionBean fb = parseFunction(function, current, false, containRaw);\n\n\t\tMap<String, Object> row = FUNCTION_MAP.get(fb.getMethod()); //FIXME  fb.getSchema() + \".\" + fb.getMethod()\n\t\tif (row == null) {\n\t\t\tthrow new UnsupportedOperationException(\"不允许调用远程函数 \" + fb.getMethod() + \" !\");\n\t\t}\n\n        String language = (String) row.get(\"language\");\n        String lang = \"java\".equalsIgnoreCase(language) ? null : language;\n\n        if (ENABLE_SCRIPT_FUNCTION == false && lang != null) {\n            throw new UnsupportedOperationException(\"language = \" + language + \" 不合法！AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION\" +\n                    \" == false 时不支持远程函数中的脚本形式！如需支持则设置 AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION = true ！\");\n        }\n\n\t\tif (lang != null && SCRIPT_EXECUTOR_MAP.get(lang) == null) {\n\t\t\tthrow new ClassNotFoundException(\"找不到脚本语言 \" + lang + \" 对应的执行引擎！请先依赖相关库并在后端 APIJSONFunctionParser<T, M, L> 中注册！\");\n\t\t}\n\n\t\tint version = row.get(\"version\") != null ? Integer.parseInt(row.get(\"version\").toString()) : 0;\n\t\tif (parser.getVersion() < version) {\n\t\t\tthrow new UnsupportedOperationException(\"不允许 version = \" + parser.getVersion() + \" 的请求调用远程函数 \" + fb.getMethod() + \" ! 必须满足 version >= \" + version + \" !\");\n\t\t}","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java#L394-L430","documentation":"Before executing a remote function, the parser looks up the method name in FUNCTION_MAP, which is loaded from the backend Function table. If no row exists for that method, it throws UnsupportedOperationException — the function is not registered server-side and therefore not callable. (Note the FIXME in source: lookup currently ignores schema, so schema-qualified names are not distinguished.)","triggerScenarios":"Request invokes function \"myFunc(...)\", but the Function table has no row with that method name; or the Function table failed to load (test/demo DB missing the apijson Function rows).","commonSituations":"Function rows never inserted into the Function table in a new environment; method name typo between client and table; FUNCTION_MAP loaded once at startup so later DB inserts require a reload/restart.","solutions":["Insert/register the function in the backend Function table (method, language, returnType, etc.).","Verify the exact method name spelling in the request matches the table row.","Restart or re-trigger FUNCTION_MAP loading after adding rows, since the map is cached.","If you meant a purely client-side expression, replace it with plain operators/columns instead of a function call."],"exampleFix":"-- before: Function table empty for myFunc\nINSERT INTO sys.Function (name, language, returnType, arguments, demo) VALUES ('myFunc', 'java', 'Number', 'key', 'myFunc(id)');\n-- then restart so FUNCTION_MAP reloads","handlingStrategy":"validation","validationCode":"if (AbstractFunctionParser.FUNCTION_MAP.get(methodName) == null) {\n    // function not registered: fail fast client-side or register it in the Function table\n}","typeGuard":"public static boolean isRegisteredFunction(String name) {\n    return AbstractFunctionParser.FUNCTION_MAP != null && AbstractFunctionParser.FUNCTION_MAP.get(name) != null;\n}","tryCatchPattern":"try { parser.invoke(fn, current); } catch (UnsupportedOperationException e) { if (e.getMessage().contains(\"不允许调用远程函数\")) { /* log missing registration, check Function table */ } throw e; }","preventionTips":["Seed the Function table via versioned SQL migrations so every environment has the rows.","After inserting rows, restart/reload so FUNCTION_MAP refreshes.","Add a smoke test after deploy that invokes one registered function."],"tags":["apijson","remote-function","registration","function-table"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}