{"record":{"id":"f2011875413b1843","repo":"Tencent/APIJSON","slug":"method-name-key-key","errorCode":null,"errorMessage":"{method}请求，{name}/{key} 里面的 {key}:[{ ... }] 中 [] 的长度不能超过 {maxUpdateCount} ！","messagePattern":"(.+?)请求，(.+?)/(.+?) 里面的 (.+?):\\[(.+?)\\] 中 \\[\\] 的长度不能超过 (.+?) ！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java","lineNumber":726,"sourceCode":"\t\t\t\t\t\t\tString finalUserIdKey = StringUtil.isEmpty(userIdKey, false) ? KEY_USER_ID : userIdKey;\n\t\t\t\t\t\t\tverifyId(method.name(), name, key, robj, finalUserIdKey, maxUpdateCount, false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn verifyRequest(method, key, tobj, robj, maxUpdateCount, database, datasource, namespace, catalog, schema, idCallback, parser);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tprotected L onParseJSONArray(String key, L tarray, L rarray) throws Exception {\n\t\t\t\tif ((method == POST || method == PUT) && isArrayKey(key)) {\n\t\t\t\t\tif (rarray == null || rarray.isEmpty()) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，请在 \" + name + \" 内传 \" + key + \":[{ ... }] \"\n\t\t\t\t\t\t\t\t+ \"，批量新增 Table[]:value 中 value 必须是包含表对象的非空数组！其中每个子项 { ... } 都是\"\n\t\t\t\t\t\t\t\t+ \" tag:\" + key.substring(0, key.length() - 2) + \" 对应单个新增的 structure ！\");\n\t\t\t\t\t}\n\t\t\t\t\tif (rarray.size() > maxUpdateCount) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t\t\t+ \" 里面的 \" + key + \":[{ ... }] 中 [] 的长度不能超过 \" + maxUpdateCount + \" ！\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn super.onParseJSONArray(key, tarray, rarray);\n\t\t\t}\n\t\t});\n\n\t}\n\n\t/**\n\t * @param method\n\t * @param name\n\t * @param key\n\t * @param robj\n\t * @param idKey\n\t * @param atLeastOne 至少有一个不为null\n\t */\n\tprivate static <T, M extends Map<String, Object>, L extends List<Object>> void verifyId(","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L708-L744","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (maxUpdateCount = 10)\nPOST { \"Comment[]\": [ /* 25 items */ ] }\n\n// after\nconst chunks = items.chunk(10);\nfor (const c of chunks) await post({ \"Comment[]\": c, \"tag\": \"Comment[]\" });","handlingStrategy":"validation","validationCode":"final int MAX = structure.getMaxUpdateCount(); // mirror the server cap\nif (items.size() > MAX) throw new ClientError(\"batch exceeds maxUpdateCount=\" + MAX + \"; split into chunks\");","typeGuard":"boolean withinBatchLimit(int size, int maxUpdateCount) { return size <= maxUpdateCount; }","tryCatchPattern":"catch (IllegalArgumentException e) when message contains \"长度不能超过\" -> 400; parse the limit from the message, chunk the array, resubmit sequentially.","preventionTips":["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."],"tags":["apijson","validation","batch-operation","limits"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}