Tencent/APIJSON · error · IllegalArgumentException
{method}请求,{name}/{key} 里面的 {key}:[{ ... }] 中 [] 的长度不能超过 {ma
Error message
{method}请求,{name}/{key} 里面的 {key}:[{ ... }] 中 [] 的长度不能超过 {maxUpdateCount} ! What it means
Companion check in onParseJSONArray: a POST/PUT batch array may not exceed maxUpdateCount (per-request cap on how many rows one request may write, e.g. Request.maxUpdateCount / defaults like 10). rarray.size() > maxUpdateCount throws IllegalArgumentException with the exact limit in the message. The cap bounds write amplification per request.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:726
String finalUserIdKey = StringUtil.isEmpty(userIdKey, false) ? KEY_USER_ID : userIdKey;
verifyId(method.name(), name, key, robj, finalUserIdKey, maxUpdateCount, false);
}
}
}
return verifyRequest(method, key, tobj, robj, maxUpdateCount, database, datasource, namespace, catalog, schema, idCallback, parser);
}
@Override
protected L onParseJSONArray(String key, L tarray, L rarray) throws Exception {
if ((method == POST || method == PUT) && isArrayKey(key)) {
if (rarray == null || rarray.isEmpty()) {
throw new IllegalArgumentException(method + "请求,请在 " + name + " 内传 " + key + ":[{ ... }] "
+ ",批量新增 Table[]:value 中 value 必须是包含表对象的非空数组!其中每个子项 { ... } 都是"
+ " tag:" + key.substring(0, key.length() - 2) + " 对应单个新增的 structure !");
}
if (rarray.size() > maxUpdateCount) {
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + key + ":[{ ... }] 中 [] 的长度不能超过 " + maxUpdateCount + " !");
}
}
return super.onParseJSONArray(key, tarray, rarray);
}
});
}
/**
* @param method
* @param name
* @param key
* @param robj
* @param idKey
* @param atLeastOne 至少有一个不为null
*/
private static <T, M extends Map<String, Object>, L extends List<Object>> void verifyId(View on GitHub (pinned to 5284052872)
Solutions
- Split the batch into chunks of at most maxUpdateCount elements and send them as multiple requests.
- If the use case legitimately needs bigger batches, raise maxUpdateCount for that tag in the Request/structure table (weigh server load).
- Enforce the limit client-side with the same constant so the server never has to reject.
Example fix
// before (maxUpdateCount = 10)
POST { "Comment[]": [ /* 25 items */ ] }
// after
const chunks = items.chunk(10);
for (const c of chunks) await post({ "Comment[]": c, "tag": "Comment[]" }); Defensive patterns
Strategy: validation
Validate before calling
final int MAX = structure.getMaxUpdateCount(); // mirror the server cap
if (items.size() > MAX) throw new ClientError("batch exceeds maxUpdateCount=" + MAX + "; split into chunks"); Type guard
boolean withinBatchLimit(int size, int maxUpdateCount) { return size <= maxUpdateCount; } Try / catch
catch (IllegalArgumentException e) when message contains "长度不能超过" -> 400; parse the limit from the message, chunk the array, resubmit sequentially.
Prevention
- Chunk batch writes client-side with the same maxUpdateCount the structure declares.
- Watch batch sizes in bulk-import code; add a client-side hard cap and progress UI for large sets.
When it happens
Trigger: A batch POST/PUT sends more elements than the configured maxUpdateCount for that tag/table, e.g. 25 items where the structure allows 10; the size check fires right after the empty-array check.
Common situations: Bulk import or sync features packing everything into one request; maxUpdateCount lowered in the Request table while clients still send large batches; front-end pagination removed during refactor letting arrays grow unbounded.
Related errors
- {method}请求,请在 {name} 内传 {key}:[{ ... }] ,批量新增 Table[]:value
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/f2011875413b1843.
Report an issue: GitHub.