Tencent/APIJSON · error · IllegalArgumentException
{method}请求,请在 {name} 内传 {key}:{} !
Error message
{method}请求,请在 {name} 内传 {key}:{} ! What it means
During structure validation in verifyRequest's parse callback onParseJSONObject: if the request object for a key is null but the target (structure) defines an object for that key, IllegalArgumentException demands the key be passed as {key}:{}. Structures mark required table objects; omitting a table the structure says must be present is a contract violation.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:671
}
//已在 Verifier 中处理
// if (get(getString(request, apijson.JSONMap.KEY_ROLE)) == ADMIN) {
// throw new IllegalArgumentException("角色设置错误!不允许在写操作Request中传 " + name +
// ":{ " + apijson.JSONMap.KEY_ROLE + ":admin } !");
// }
//解析
return parse(method, name, target, request, database, datasource, namespace, catalog, schema, idCallback, parser, new OnParseCallback<T, M, L>() {
@Override
public M onParseJSONObject(String key, M tobj, M robj) throws Exception {
// Log.i(TAG, "verifyRequest.parse.onParseJSONObject key = " + key + "; robj = " + robj);
if (robj == null) {
if (tobj != null) {//不允许不传Target中指定的Table
throw new IllegalArgumentException(method + "请求,请在 " + name + " 内传 " + key + ":{} !");
}
} else if (isTableKey(key)) {
String db = getString(request, KEY_DATABASE);
String ds = getString(request, KEY_DATASOURCE);
String ns = getString(request, KEY_NAMESPACE);
String cl = getString(request, KEY_CATALOG);
String sh = getString(request, KEY_SCHEMA);
if (StringUtil.isEmpty(db, false)) {
db = database;
}
if (StringUtil.isEmpty(ds, false)) {
ds = datasource;
}
if (StringUtil.isEmpty(ns, false)) {
ns = namespace;
}
if (StringUtil.isEmpty(cl, false)) {
cl = catalog;View on GitHub (pinned to 5284052872)
Solutions
- Add the missing table object to the request: {"<key>": { ... }} as required by the structure.
- If the table should genuinely be optional, update the structure/Request table row (target JSON) so it does not force the key.
- Keep structure definitions and the front-end request builder in sync via a shared schema or generated types.
Example fix
// before
// structure requires: { "User": { "MUST": "id" } }
{ "tag": "User", "params": { } }
// after
{ "tag": "User", "params": { "User": { "id": 1 } } } Defensive patterns
Strategy: validation
Validate before calling
// client: before send, ensure every table key required by the structure's target is present
for (String k : structureTargetKeys) {
if (isTableKey(k) && !request.containsKey(k)) clientError("missing required table object " + k);
} Type guard
boolean satisfiesRequiredTables(Set<String> required, Map<String,Object> req) { return required.stream().filter(this::isTableKey).allMatch(req::containsKey); } Try / catch
catch (IllegalArgumentException e) when message contains "内传" -> 400 with the missing key name; client re-renders the form section.
Prevention
- Generate request DTOs from the structure (Request table) so required tables are compile-time visible.
- Version structures with the client release; reject mismatched structure/client pairs at the edge.
When it happens
Trigger: A POST/PUT with a structure (Request table row) that specifies table object "User" in its target, while the client's request JSON omits "User" entirely; robj == null with tobj != null triggers the throw.
Common situations: Client version drift — newer optional-field handling drops a table the structure still requires; hand-written requests missing a mandatory sub-table; structure row edited to require a table that the front-end flow never sends; nested batch structures where an inner table is skipped.
Related errors
- 角色 {} 不存在!只能是[{}]中的一种!
- {}.id 类型错误,类型必须是 Long/String!
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/0981fd8579cca6db.
Report an issue: GitHub.