{"record":{"id":"bcbbbac4389bba35","repo":"apache/incubator-seata","slug":"pagesize-range-not-in-min-page-size","errorCode":null,"errorMessage":"\"pageSize range not in [\" + MIN_PAGE_SIZE + \"-\" + MAX_PAGE_SIZE + \"]\"","messagePattern":"\"pageSize range not in \\[\" \\+ MIN_PAGE_SIZE \\+ \"-\" \\+ MAX_PAGE_SIZE \\+ \"\\]\"","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"common/src/main/java/org/apache/seata/common/util/PageUtil.java","lineNumber":96,"sourceCode":"    /**\n     * The constant SQLSERVER_PAGE_TEMPLATE. Currently, it only works for order-by condition of \"ORDER BY gmt_create desc\"\n     */\n    private static final String SQLSERVER_PAGE_TEMPLATE =\n            \"select * from (select temp.*, ROW_NUMBER() OVER(ORDER BY gmt_create desc) AS rowId from (\"\n                    + SOURCE_SQL_PLACE_HOLD + \") temp ) t where t.rowId between \" + START_PLACE_HOLD + \" and \"\n                    + END_PLACE_HOLD;\n    /**\n     * check page parm\n     *\n     * @param pageNum the page num\n     * @param pageSize the page size\n     */\n    public static void checkParam(int pageNum, int pageSize) {\n        if (!(pageNum >= MIN_PAGE_NUM && pageNum <= MAX_PAGE_NUM)) {\n            throw new IllegalArgumentException(\"pageNum range not in [\" + MIN_PAGE_NUM + \"-\" + MAX_PAGE_NUM + \"]\");\n        }\n        if (!(pageSize >= MIN_PAGE_SIZE && pageSize <= MAX_PAGE_SIZE)) {\n            throw new IllegalArgumentException(\"pageSize range not in [\" + MIN_PAGE_SIZE + \"-\" + MAX_PAGE_SIZE + \"]\");\n        }\n    }\n\n    /**\n     * get pagesql\n     *\n     * @param sourceSql the source sql\n     * @param dbType the db type\n     * @param pageNum the page num\n     * @param pageSize the page size\n     * @return the page sql\n     */\n    public static String pageSql(String sourceSql, String dbType, int pageNum, int pageSize) {\n        switch (dbType) {\n            case \"mysql\":\n            case \"h2\":\n            case \"postgresql\":\n            case \"kingbase\":","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/util/PageUtil.java#L78-L114","documentation":"PageUtil.checkParam's second bound: page size must be within [MIN_PAGE_SIZE=1, MAX_PAGE_SIZE=100]. A pageSize of 0, negative, or above 100 throws IllegalArgumentException listing the allowed range. The cap protects the server from oversized page queries.","triggerScenarios":"Calling PageUtil.checkParam(pageNum, pageSize) (or the console list endpoints that delegate to it) with pageSize=0, a negative value, or e.g. pageSize=500 to 'fetch everything at once'.","commonSituations":"Clients exporting large lists set a huge pageSize; misconfigured frontends defaulting to 0; API consumers assuming 'size=0 means unlimited'.","solutions":["Request pages of at most 100 items and iterate over pages","Clamp: Math.min(Math.max(pageSize, 1), PageUtil.MAX_PAGE_SIZE)","For bulk retrieval, loop pageNum=1..N with size 100 rather than raising size"],"exampleFix":"// before\nPageUtil.checkParam(1, 500); // throws\n\n// after\nint size = Math.min(Math.max(requestedSize, PageUtil.MIN_PAGE_SIZE), PageUtil.MAX_PAGE_SIZE);\nPageUtil.checkParam(1, size);","handlingStrategy":"validation","validationCode":"int pageSize = Math.min(Math.max(requestedSize, PageUtil.MIN_PAGE_SIZE), PageUtil.MAX_PAGE_SIZE);\nPageUtil.checkParam(pageNum, pageSize);","typeGuard":null,"tryCatchPattern":"try { PageUtil.checkParam(p, s); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body(e.getMessage()); }","preventionTips":["Cap page size at 100 and iterate for bulk data","Never use 0 as 'unlimited' size","Expose allowed ranges in API docs so clients validate before sending"],"tags":["pagination","api","console","validation"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}