{"record":{"id":"feca60b55ab3a7f4","repo":"Tencent/APIJSON","slug":"page-value-value","errorCode":null,"errorMessage":"{}/page:value 中 value 的值不合法！必须在 {}-{} 内 !","messagePattern":"(.+?)/page:value 中 value 的值不合法！必须在 (.+?)-(.+?) 内 !","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":1372,"sourceCode":"\t\t\tcase \"1\":\n\t\t\tcase apijson.JSONRequest.QUERY_TOTAL_STRING:\n\t\t\t\tquery2 = apijson.JSONRequest.QUERY_TOTAL;\n\t\t\t\tbreak;\n\t\t\tcase \"2\":\n\t\t\tcase apijson.JSONRequest.QUERY_ALL_STRING:\n\t\t\t\tquery2 = apijson.JSONRequest.QUERY_ALL;\n\t\t\t\tbreak;\n\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都无效！！！ 后续都不执行，没必要还原数组关键词浪费性能","sourceCodeStart":1354,"sourceCodeEnd":1390,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L1354-L1390","documentation":"The page number in []:{} is normalized (page or 0, minus getMinQueryPage(), commonly 0- or 1-based compat) and must fall in [0..getMaxQueryPage()]. Outside that range IllegalArgumentException is thrown with the exact min-max bounds in the message.","triggerScenarios":"{\"[]\":{\"page\":100000,...}} beyond maxQueryPage (default 100), or a negative page, or page after normalization below 0 because the client assumed a different min-page base than the server uses.","commonSituations":"Client computes page from total/count without ceiling; infinite-scroll keeps incrementing past the cap; server tightened maxQueryPage to limit scan depth; off-by-one when minQueryPage is 1 on server but client sends 0-based 0 with negative computed index on another deploy.","solutions":["Clamp page client-side to the range shown in the message (typically 0-100 or 1-100)","When deep-paginating, use @column with ordered unique keys or @explain'd keyset pagination instead of high offsets","Align the client's page base with getMinQueryPage() of the server","Raise getMaxQueryPage() in your Parser subclass only if the data volume justifies it"],"exampleFix":"// before\n{\"[]\":{\"page\":101,\"count\":10,\"User\":{}}}\n// after\n{\"[]\":{\"page\":100,\"count\":10,\"User\":{}}}","handlingStrategy":"validation","validationCode":"int p = page == null ? 0 : page;\nif (p < 0 || p > MAX_PAGE) throw new IllegalArgumentException(\"page out of range: \" + p);","typeGuard":"boolean pageInRange(Integer page, int min, int max) {\n  return page == null || (page >= min && page <= max);\n}","tryCatchPattern":null,"preventionTips":["Clamp page in the pager component using the server-advertised max","Stop paginating when a response has fewer rows than count instead of probing higher pages","Keyset-paginate with @order + @column for deep access"],"tags":["apijson","pagination","page","range-validation"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}