Tencent/APIJSON · error · UnsupportedOperationException

{method} 请求,{name} 里面不允许传 {rk}:{} !

Error message

{method} 请求,{name} 里面不允许传 {rk}:{} !

What it means

Thrown when the client sends a nested object for a key that is not declared as an object in the target (Request-table template) and is not an @-prefixed/suffixed operator key. Only keys defined in the template may carry {} values; undefined {} keys are rejected to prevent injecting arbitrary structures.

Source

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

			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)) {
//				onKeys.add(rk);
//			}
		}
		// 判断不允许传的key>>>>>>>>>>>>>>>>>>>>>>>>>


View on GitHub (pinned to 5284052872)

Solutions

  1. Remove the undefined key:{} from the request
  2. Have the backend add the nested key to the Request-table target template so it becomes an allowed object
  3. Flatten nested data into scalar columns if the schema does not support the sub-object

Example fix

// before
{"User":{"name":"a","profile":{"age":1}}}
// after
{"User":{"name":"a"}}
Defensive patterns

Strategy: validation

Validate before calling

// allowedObjectKeys: keys the template declares as objects
function assertNoUndefinedObjects(obj, allowedObjectKeys) {
  for (const k of Object.keys(obj)) {
    const v = obj[k];
    if (v != null && typeof v === 'object' && !Array.isArray(v)
        && !k.startsWith('@') && !k.endsWith('@') && !allowedObjectKeys.includes(k)) {
      throw new TypeError(`nested object not allowed for key: ${k}`);
    }
  }
}

Type guard

const isAllowedNestedObject = (k, v, allowed) => !(v instanceof Object && !(v instanceof Array)) || k.startsWith('@') || k.endsWith('@') || allowed.includes(k);

Prevention

When it happens

Trigger: POST {"User":{"name":"a","profile":{"age":1}}} where the template for User defines only scalar keys and no 'profile' object — objKeySet does not contain 'profile' and rv is a Map.

Common situations: Client adds a new nested field before the backend template is extended; sending a full domain object with sub-objects to a strictly-defined endpoint; misunderstanding that every nested {} must be whitelisted in the Request table.

Related errors


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