{"record":{"id":"5ae52ca5a0cf94ac","repo":"Tencent/APIJSON","slug":"count-value-value-0","errorCode":null,"errorMessage":"{}/count:value 中 value 的值不合法！必须在 0-{} 内 !","messagePattern":"(.+?)/count:value 中 value 的值不合法！必须在 0-(.+?) 内 !","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":1380,"sourceCode":"\t\t\tdefault:\n\t\t\t\tthrow new IllegalArgumentException(path + \"/\" + apijson.JSONRequest.KEY_QUERY + \":value 中 value 的值不合法！必须在 [0, 1, 2] 或 [TABLE, TOTAL, ALL] 内 !\");\n\t\t\t}\n\t\t}\n\n\t\tint minPage = getMinQueryPage(); // 兼容各种传 0 或 null/undefined 自动转 0 导致的问题\n\t\tint page2 = page == null || page == 0 ? 0 : page - minPage;\n\n\t\tint maxPage = getMaxQueryPage();\n\t\tif (page2 < 0 || page2 > maxPage) {\n\t\t\tthrow new IllegalArgumentException(path + \"/\" + apijson.JSONRequest.KEY_PAGE + \":value 中 value 的值不合法！必须在 \" + minPage + \"-\" + maxPage + \" 内 !\");\n\t\t}\n\n\t\t//不用total限制数量了，只用中断机制，total只在query = 1,2的时候才获取\n\t\tint count2 = isSubquery || count != null ? (count == null ? 0 : count) : getDefaultQueryCount();\n\t\tint max = isSubquery ? count2 : getMaxQueryCount();\n\n\t\tif (count2 < 0 || count2 > max) {\n\t\t\tthrow new IllegalArgumentException(path + \"/\" + apijson.JSONRequest.KEY_COUNT + \":value 中 value 的值不合法！必须在 0-\" + max + \" 内 !\");\n\t\t}\n\n\t\trequest.remove(apijson.JSONRequest.KEY_QUERY);\n\t\trequest.remove(apijson.JSONRequest.KEY_COMPAT);\n\t\trequest.remove(apijson.JSONRequest.KEY_COUNT);\n\t\trequest.remove(apijson.JSONRequest.KEY_PAGE);\n\t\trequest.remove(apijson.JSONRequest.KEY_JOIN);\n\t\tLog.d(TAG, \"onArrayParse  query = \" + query + \"; count = \" + count + \"; page = \" + page + \"; join = \" + join);\n\n\t\tif (request.isEmpty()) { // 如果条件成立，说明所有的 parentPath/name:request 中request都无效！！！ 后续都不执行，没必要还原数组关键词浪费性能\n\t\t\tLog.e(TAG, \"onArrayParse  request.isEmpty() >> return null;\");\n\t\t\treturn null;\n\t\t}\n\n\t\tL response = null;\n\t\ttry {\n\t\t\tint size = count2 == 0 ? max : count2; //count为每页数量，size为第page页实际数量，max(size) = count\n\t\t\tLog.d(TAG, \"onArrayParse  size = \" + size + \"; page = \" + page2);","sourceCodeStart":1362,"sourceCodeEnd":1398,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L1362-L1398","documentation":"count (rows per page) in []:{} defaults to getDefaultQueryCount() when absent; when provided (or in subqueries) it must be within 0..max, where max is getMaxQueryCount() for top-level arrays or count2 itself for subqueries. Negative or oversized values throw IllegalArgumentException with the exact 0-max bound.","triggerScenarios":"{\"[]\":{\"count\":1000,...}} with server maxQueryCount=100 (typical default 10) ; count:-5; subquery arrays carrying a count larger than allowed.","commonSituations":"Export features requesting all rows in one page; frontend grid page-size selector offering values above the server cap; ops lowered maxQueryCount for load reasons; migrating configs where the default count changed between versions.","solutions":["Lower count to at most getMaxQueryCount() (message shows the max) and paginate with page","For bulk export loop pages with a server-allowed count instead of one big count","Override getMaxQueryCount() in your Parser subclass if the deployment can afford larger pages","Remove count and rely on the default when you only need the standard page size"],"exampleFix":"// before\n{\"[]\":{\"count\":1000,\"User\":{}}}\n// after\n{\"[]\":{\"count\":100,\"page\":0,\"User\":{}}}","handlingStrategy":"validation","validationCode":"int c = count == null ? DEFAULT_COUNT : count;\nif (c < 0 || c > MAX_COUNT) throw new IllegalArgumentException(\"count out of range: \" + c);","typeGuard":"boolean countInRange(Integer count, int max) {\n  return count == null || (count >= 0 && count <= max);\n}","tryCatchPattern":null,"preventionTips":["Cap page-size selectors at the server's maxQueryCount","Loop pages for exports; never ask for all rows at once","Read the exact max from the error message and encode it in client config"],"tags":["apijson","pagination","count","range-validation"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}