apache/incubator-seata · warning · IllegalArgumentException

"pageSize range not in [" + MIN_PAGE_SIZE + "-" +…

Error message

"pageSize range not in [" + MIN_PAGE_SIZE + "-" + MAX_PAGE_SIZE + "]"

What it means

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.

Solutions

  1. Request pages of at most 100 items and iterate over pages
  2. Clamp: Math.min(Math.max(pageSize, 1), PageUtil.MAX_PAGE_SIZE)
  3. For bulk retrieval, loop pageNum=1..N with size 100 rather than raising size

Example fix

// before
PageUtil.checkParam(1, 500); // throws

// after
int size = Math.min(Math.max(requestedSize, PageUtil.MIN_PAGE_SIZE), PageUtil.MAX_PAGE_SIZE);
PageUtil.checkParam(1, size);
Defensive patterns

Strategy: validation

Validate before calling

int pageSize = Math.min(Math.max(requestedSize, PageUtil.MIN_PAGE_SIZE), PageUtil.MAX_PAGE_SIZE);
PageUtil.checkParam(pageNum, pageSize);

Try / catch

try { PageUtil.checkParam(p, s); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body(e.getMessage()); }

Prevention

When it happens

Trigger: 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'.

Common situations: Clients exporting large lists set a huge pageSize; misconfigured frontends defaulting to 0; API consumers assuming 'size=0 means unlimited'.

Related errors


AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14). Data as JSON: /api/errors/bcbbbac4389bba35. Report an issue: GitHub.

Appendix: source

Thrown at common/src/main/java/org/apache/seata/common/util/PageUtil.java:96

    /**
     * The constant SQLSERVER_PAGE_TEMPLATE. Currently, it only works for order-by condition of "ORDER BY gmt_create desc"
     */
    private static final String SQLSERVER_PAGE_TEMPLATE =
            "select * from (select temp.*, ROW_NUMBER() OVER(ORDER BY gmt_create desc) AS rowId from ("
                    + SOURCE_SQL_PLACE_HOLD + ") temp ) t where t.rowId between " + START_PLACE_HOLD + " and "
                    + END_PLACE_HOLD;
    /**
     * check page parm
     *
     * @param pageNum the page num
     * @param pageSize the page size
     */
    public static void checkParam(int pageNum, int pageSize) {
        if (!(pageNum >= MIN_PAGE_NUM && pageNum <= MAX_PAGE_NUM)) {
            throw new IllegalArgumentException("pageNum range not in [" + MIN_PAGE_NUM + "-" + MAX_PAGE_NUM + "]");
        }
        if (!(pageSize >= MIN_PAGE_SIZE && pageSize <= MAX_PAGE_SIZE)) {
            throw new IllegalArgumentException("pageSize range not in [" + MIN_PAGE_SIZE + "-" + MAX_PAGE_SIZE + "]");
        }
    }

    /**
     * get pagesql
     *
     * @param sourceSql the source sql
     * @param dbType the db type
     * @param pageNum the page num
     * @param pageSize the page size
     * @return the page sql
     */
    public static String pageSql(String sourceSql, String dbType, int pageNum, int pageSize) {
        switch (dbType) {
            case "mysql":
            case "h2":
            case "postgresql":
            case "kingbase":

View on GitHub (pinned to e01f97c6db)