{"record":{"id":"11e82d2e7e269249","repo":"Tencent/APIJSON","slug":"method-name-rk","errorCode":null,"errorMessage":"{method} 请求，{name} 里面不允许传 {rk}:{} ！","messagePattern":"(.+?) 请求，(.+?) 里面不允许传 (.+?):(.+?) ！","errorType":"validation","errorClass":"UnsupportedOperationException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java","lineNumber":1147,"sourceCode":"\n\t\t\tObject rv = real.get(rk);\n\t\t\tif (rv != null && stringKeyList != null && stringKeyList.contains(rk)) {\n\t\t\t\trv = toJSONString(rv);\n\t\t\t}\n\t\t\tif (rv != null && trimKeyList != null && trimKeyList.contains(rk)) {\n\t\t\t\trv = StringUtil.trim(rv);\n\t\t\t}\n\n\t\t\t// 不允许传远程函数，只能后端配置\n\t\t\tif (rk.endsWith(\"()\") && rv instanceof String) {\n\t\t\t\tthrow new UnsupportedOperationException(method + \" 请求，\" + rk + \" 不合法！\" +\n                        \"非开放请求不允许传远程函数 key():\\\"fun()\\\" ！\");\n\t\t\t}\n\n\t\t\t// 不在target内的 key:{}\n\t\t\tif (rk.startsWith(\"@\") == false && rk.endsWith(\"@\") == false && objKeySet.contains(rk) == false) {\n\t\t\t\tif (rv instanceof Map<?, ?>) {\n\t\t\t\t\tthrow new UnsupportedOperationException(method + \" 请求，\"\n                            + name + \" 里面不允许传 \" + rk + \":{} ！\");\n\t\t\t\t}\n\t\t\t\tif ((method == POST || method == PUT)\n                        && rv instanceof List<?> && isArrayKey(rk)) {\n\t\t\t\t\tthrow new UnsupportedOperationException(method + \" 请求，\" + name + \" 里面不允许 \"\n                            + rk + \":[] 等未定义的 Table[]:[{}] 批量操作键值对！\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 先让其它操作符完成\n//\t\t\tif (rv != null) { // || nulls.contains(rk)) {\n//\t\t\t\tonKeys.add(rk);\n//\t\t\t}\n\t\t}\n\t\t// 判断不允许传的key>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n","sourceCodeStart":1129,"sourceCodeEnd":1165,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L1129-L1165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{\"User\":{\"name\":\"a\",\"profile\":{\"age\":1}}}\n// after\n{\"User\":{\"name\":\"a\"}}","handlingStrategy":"validation","validationCode":"// allowedObjectKeys: keys the template declares as objects\nfunction assertNoUndefinedObjects(obj, allowedObjectKeys) {\n  for (const k of Object.keys(obj)) {\n    const v = obj[k];\n    if (v != null && typeof v === 'object' && !Array.isArray(v)\n        && !k.startsWith('@') && !k.endsWith('@') && !allowedObjectKeys.includes(k)) {\n      throw new TypeError(`nested object not allowed for key: ${k}`);\n    }\n  }\n}","typeGuard":"const isAllowedNestedObject = (k, v, allowed) => !(v instanceof Object && !(v instanceof Array)) || k.startsWith('@') || k.endsWith('@') || allowed.includes(k);","tryCatchPattern":null,"preventionTips":["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"],"tags":["apijson","undefined-key","structure","request-table"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}