{"record":{"id":"c06cfffcf9a4bb9a","repo":"apache/incubator-seata","slug":"pagenum-range-not-in-min-page-num-ma","errorCode":null,"errorMessage":"\"pageNum range not in [\" + MIN_PAGE_NUM + \"-\" + MAX_PAGE_NUM + \"]\"","messagePattern":"\"pageNum range not in \\[\" \\+ MIN_PAGE_NUM \\+ \"-\" \\+ MAX_PAGE_NUM \\+ \"\\]\"","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"common/src/main/java/org/apache/seata/common/util/PageUtil.java","lineNumber":93,"sourceCode":"    private static final String ORACLE_PAGE_TEMPLATE = \"select * from ( select ROWNUM rn, temp.* from (\"\n            + SOURCE_SQL_PLACE_HOLD + \") temp ) where rn between \" + START_PLACE_HOLD + \" and \" + END_PLACE_HOLD;\n\n    /**\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\":","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/util/PageUtil.java#L75-L111","documentation":"PageUtil.checkParam enforces server-side pagination limits for Seata's paged queries (console/session/lock list endpoints). Page numbers must be within [MIN_PAGE_NUM=1, MAX_PAGE_NUM=999]; a pageNum of 0 or below, or above 999, throws IllegalArgumentException with the allowed range in the message.","triggerScenarios":"Calling PageUtil.checkParam(pageNum, pageSize) — directly or via console list APIs — with pageNum=0 (common when a caller computes pageNum from an offset incorrectly) or pageNum > 999.","commonSituations":"Frontend sending page=0 because it uses zero-based paging while the API is one-based; a UI letting users jump to an arbitrarily high page; automated clients looping past page 999.","solutions":["Send pageNum in [1,999]; convert zero-based UI indices with pageNum = index + 1","Clamp pageNum before calling: Math.min(Math.max(pageNum, 1), 999)","Return an empty result instead of querying when the requested page exceeds total pages"],"exampleFix":"// before\nPageUtil.checkParam(0, 10); // throws\n\n// after\nint safe = Math.min(Math.max(requestedPage, PageUtil.MIN_PAGE_NUM), PageUtil.MAX_PAGE_NUM);\nPageUtil.checkParam(safe, 10);","handlingStrategy":"validation","validationCode":"int pageNum = Math.min(Math.max(requestedPage, PageUtil.MIN_PAGE_NUM), PageUtil.MAX_PAGE_NUM);\nPageUtil.checkParam(pageNum, pageSize);","typeGuard":null,"tryCatchPattern":"try { PageUtil.checkParam(p, s); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body(e.getMessage()); }","preventionTips":["Translate 0-based UI paging to 1-based before calling server APIs","Clamp page parameters at the API boundary","Return 400 responses instead of 500s for out-of-range paging"],"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"}