Tencent/APIJSON · error · UnsupportedOperationException

{method} 请求,{rk} 不合法!非开放请求不允许传远程函数 key():"fun()" !

Error message

{method} 请求,{rk} 不合法!非开放请求不允许传远程函数 key():"fun()" !

What it means

Thrown when a non-open request contains a remote-function pair — a key ending in () with a String value, e.g. "isPrime()": "isPrime(id)". Remote functions must be configured server-side; client-supplied ones would let callers execute arbitrary registered functions.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:1140

				throw new UnsupportedOperationException(method + " 请求," + rk + " 不合法!" +
						"非开放请求不允许传 " + KEY_COMBINE + ":value !");
			}
			if (KEY_KEY.equals(rk)) {
				throw new UnsupportedOperationException(method + " 请求," + rk + " 不合法!" +
						"非开放请求不允许传 " + KEY_KEY + ":value !");
			}

			Object rv = real.get(rk);
			if (rv != null && stringKeyList != null && stringKeyList.contains(rk)) {
				rv = toJSONString(rv);
			}
			if (rv != null && trimKeyList != null && trimKeyList.contains(rk)) {
				rv = StringUtil.trim(rv);
			}

			// 不允许传远程函数,只能后端配置
			if (rk.endsWith("()") && rv instanceof String) {
				throw new UnsupportedOperationException(method + " 请求," + rk + " 不合法!" +
                        "非开放请求不允许传远程函数 key():\"fun()\" !");
			}

			// 不在target内的 key:{}
			if (rk.startsWith("@") == false && rk.endsWith("@") == false && objKeySet.contains(rk) == false) {
				if (rv instanceof Map<?, ?>) {
					throw new UnsupportedOperationException(method + " 请求,"
                            + name + " 里面不允许传 " + rk + ":{} !");
				}
				if ((method == POST || method == PUT)
                        && rv instanceof List<?> && isArrayKey(rk)) {
					throw new UnsupportedOperationException(method + " 请求," + name + " 里面不允许 "
                            + rk + ":[] 等未定义的 Table[]:[{}] 批量操作键值对!");
				}
			}

			// 先让其它操作符完成
//			if (rv != null) { // || nulls.contains(rk)) {

View on GitHub (pinned to 5284052872)

Solutions

  1. Remove all key():"fun()" entries from the client request
  2. Ask the backend to register the function in the Function table and reference it from the Request-table config
  3. Compute derived values client-side or via a dedicated endpoint

Example fix

// before
{"User":{"id":1,"isPrime()":"isPrime(id)"}}
// after
{"User":{"id":1}}
Defensive patterns

Strategy: validation

Validate before calling

function stripRemoteFunctions(obj) {
  const out = {};
  for (const k of Object.keys(obj)) if (!k.endsWith('()')) out[k] = obj[k];
  return out;
}

Type guard

const isRemoteFunctionKey = (k) => k.endsWith('()');

Prevention

When it happens

Trigger: Request body includes {"User":{"id":1,"isPrime()":"isPrime(id)"}} on a non-open request — rk.endsWith("()") && rv instanceof String.

Common situations: Copying demo payloads from APIJSON docs that showcase remote functions; frontend computing derived values by invoking server functions per row; testing function tags against a locked tag.

Related errors


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