Tencent/APIJSON · error · IllegalArgumentException
{}/count:value 中 value 的值不合法!必须在 0-{} 内 !
Error message
{}/count:value 中 value 的值不合法!必须在 0-{} 内 ! What it means
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.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:1380
default:
throw new IllegalArgumentException(path + "/" + apijson.JSONRequest.KEY_QUERY + ":value 中 value 的值不合法!必须在 [0, 1, 2] 或 [TABLE, TOTAL, ALL] 内 !");
}
}
int minPage = getMinQueryPage(); // 兼容各种传 0 或 null/undefined 自动转 0 导致的问题
int page2 = page == null || page == 0 ? 0 : page - minPage;
int maxPage = getMaxQueryPage();
if (page2 < 0 || page2 > maxPage) {
throw new IllegalArgumentException(path + "/" + apijson.JSONRequest.KEY_PAGE + ":value 中 value 的值不合法!必须在 " + minPage + "-" + maxPage + " 内 !");
}
//不用total限制数量了,只用中断机制,total只在query = 1,2的时候才获取
int count2 = isSubquery || count != null ? (count == null ? 0 : count) : getDefaultQueryCount();
int max = isSubquery ? count2 : getMaxQueryCount();
if (count2 < 0 || count2 > max) {
throw new IllegalArgumentException(path + "/" + apijson.JSONRequest.KEY_COUNT + ":value 中 value 的值不合法!必须在 0-" + max + " 内 !");
}
request.remove(apijson.JSONRequest.KEY_QUERY);
request.remove(apijson.JSONRequest.KEY_COMPAT);
request.remove(apijson.JSONRequest.KEY_COUNT);
request.remove(apijson.JSONRequest.KEY_PAGE);
request.remove(apijson.JSONRequest.KEY_JOIN);
Log.d(TAG, "onArrayParse query = " + query + "; count = " + count + "; page = " + page + "; join = " + join);
if (request.isEmpty()) { // 如果条件成立,说明所有的 parentPath/name:request 中request都无效!!! 后续都不执行,没必要还原数组关键词浪费性能
Log.e(TAG, "onArrayParse request.isEmpty() >> return null;");
return null;
}
L response = null;
try {
int size = count2 == 0 ? max : count2; //count为每页数量,size为第page页实际数量,max(size) = count
Log.d(TAG, "onArrayParse size = " + size + "; page = " + page2);View on GitHub (pinned to 5284052872)
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
Example fix
// before
{"[]":{"count":1000,"User":{}}}
// after
{"[]":{"count":100,"page":0,"User":{}}} Defensive patterns
Strategy: validation
Validate before calling
int c = count == null ? DEFAULT_COUNT : count;
if (c < 0 || c > MAX_COUNT) throw new IllegalArgumentException("count out of range: " + c); Type guard
boolean countInRange(Integer count, int max) {
return count == null || (count >= 0 && count <= max);
} Prevention
- 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
When it happens
Trigger: {"[]":{"count":1000,...}} with server maxQueryCount=100 (typical default 10) ; count:-5; subquery arrays carrying a count larger than allowed.
Common situations: 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.
Related errors
- {}/page:value 中 value 的值不合法!必须在 {}-{} 内 !
- {}/query:value 中 value 的值不合法!必须在 [0, 1, 2] 或 [TABLE, TOTAL,
- join:'${e.getKey()}' 对应的 ${arrKey}:{ page: value } 中 value 不
- Value for key '" + key + "' is not a Map: " + value.getClass
- Value for key '" + key + "' is not a List: " + value.getClas
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/5ae52ca5a0cf94ac.
Report an issue: GitHub.