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
- Remove the undefined key:{} from the request
- Have the backend add the nested key to the Request-table target template so it becomes an allowed object
- 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
- Keep a client-side schema of allowed keys per endpoint (scalars vs objects)
- Add new nested fields to the Request-table template before clients send them
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
- {key}:value 的 value 不合法!类型必须是 OBJECT ,结构为 {} !
- 找不到 version: ${version}, method: ${method.name()}, tag: ${ta
- {method}请求,请在 {name} 内传 {key}:{} !
- {name}: { IF: value } 中 value 类型错误!只允许 String, JSONRequest!
- {method}请求,{name} 里面不能缺少 {field} 等[{must}]内的任何字段!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/11e82d2e7e269249.
Report an issue: GitHub.