Tencent/APIJSON · error · UnsupportedOperationException

不允许 tag = " + parser.getTag() + " 的请求调用远程函数 " + fb.getMethod

Error message

不允许 tag = " + parser.getTag() + " 的请求调用远程函数 " + fb.getMethod() + " ! 必须满足 tag = " + tag + " !

What it means

Function rows may declare a required tag; the parser compares it with parser.getTag() (typically from the request's @tag, used to route to different database clusters/environments). A mismatch throws UnsupportedOperationException, preventing a function bound to one environment tag from being invoked by requests tagged differently.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java:433

        String language = (String) row.get("language");
        String lang = "java".equalsIgnoreCase(language) ? null : language;

        if (ENABLE_SCRIPT_FUNCTION == false && lang != null) {
            throw new UnsupportedOperationException("language = " + language + " 不合法!AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION" +
                    " == false 时不支持远程函数中的脚本形式!如需支持则设置 AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION = true !");
        }

		if (lang != null && SCRIPT_EXECUTOR_MAP.get(lang) == null) {
			throw new ClassNotFoundException("找不到脚本语言 " + lang + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser<T, M, L> 中注册!");
		}

		int version = row.get("version") != null ? Integer.parseInt(row.get("version").toString()) : 0;
		if (parser.getVersion() < version) {
			throw new UnsupportedOperationException("不允许 version = " + parser.getVersion() + " 的请求调用远程函数 " + fb.getMethod() + " ! 必须满足 version >= " + version + " !");
		}
		String tag = (String) row.get("tag");  // TODO 改为 tags,类似 methods 支持多个 tag。或者干脆不要?因为目前非开放请求全都只能后端指定
		if (tag != null && tag.equals(parser.getTag()) == false) {
			throw new UnsupportedOperationException("不允许 tag = " + parser.getTag() + " 的请求调用远程函数 " + fb.getMethod() + " ! 必须满足 tag = " + tag + " !");
		}
		String[] methods = StringUtil.split((String) row.get("methods"));
		List<String> ml = methods == null || methods.length <= 0 ? null : Arrays.asList(methods);
		if (ml != null && ml.contains(parser.getMethod().toString()) == false) {
			throw new UnsupportedOperationException("不允许 method = " + parser.getMethod() + " 的请求调用远程函数 " + fb.getMethod() + " ! 必须满足 method 在 " + Arrays.toString(methods) + "内 !");
		}

		try {
            return invoke(parser, fb.getMethod(), fb.getTypes(), fb.getValues(), (String) row.get("returnType"), current, SCRIPT_EXECUTOR_MAP.get(lang));
		}
        catch (Exception e) {
			if (e instanceof NoSuchMethodException) {
				throw new IllegalArgumentException("字符 " + function + " 对应的远程函数 " + getFunction(fb.getMethod(), fb.getKeys())
                        + " 不在后端 " + parser.getClass().getName() + " 内,也不在父类中!如果需要则先新增对应方法!"
						+ "\n请检查函数名和参数数量是否与已定义的函数一致!"
						+ "\n且必须为 function(key0,key1,...) 这种单函数格式!"
						+ "\nfunction 必须符合 Java 函数命名,key 是用于在 curObj 内取值的键!"
						+ "\n调用时不要有空格!" + (Log.DEBUG ? e.getMessage() : ""));

View on GitHub (pinned to 5284052872)

Solutions

  1. Send the matching tag in the request: "@tag": "online" (or whatever the Function row requires).
  2. Or update/clear the Function row's tag column to match the environment's clients.
  3. Audit all Function rows' tags when copying them between environments.

Example fix

// before
{"User":{"@column":"enc(id)"}} // row tag='online', request tag=null

// after
{"@tag":"online", "User":{"@column":"enc(id)"}}
Defensive patterns

Strategy: validation

Validate before calling

String rowTag = (String) functionRow.get("tag");
if (rowTag != null && !rowTag.equals(requestTag)) {
    // set "@tag": rowTag in the request, or clear/adjust the row's tag
}

Try / catch

try { parser.invoke(fn, current); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("tag")) { /* align request @tag with Function row */ } throw e; }

Prevention

When it happens

Trigger: Function row sets tag='online' (or 'test') while the request's @tag is absent or different, so parser.getTag() does not equal the configured tag.

Common situations: Functions registered for the test cluster but the request omits @tag (defaults to null); promoting Function rows between environments without updating their tag; client sends the wrong tag constant.

Related errors


AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14). Data as JSON: /api/errors/b1735e9d76b45722. Report an issue: GitHub.