Tencent/APIJSON · error · IllegalArgumentException
{method}请求,{name}/{key} 里面的 {idInKey}:[] 中所有项都不能为 [ null, <=
Error message
{method}请求,{name}/{key} 里面的 {idInKey}:[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 "" ] 中任何一个 ! What it means
Thrown by verifyId while iterating id{} items: an element is null. Every item must be a usable id — null, numbers <= 0, and empty strings are all rejected so the generated IN(...) clause stays well-formed.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java:781
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + idInKey + ":value 中value的类型只能是 [Long] !");
}
if (idIn == null) {
if (atLeastOne && id == null && idRefInKey == null) {
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面 " + idKey + "," + idInKey + "," + (idKey + "{}@") + " 至少传其中一个!");
}
} else {
if (idIn.size() > maxUpdateCount) { //不允许一次操作 maxUpdateCount 条以上记录
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + idInKey + ":[] 中[]的长度不能超过 " + maxUpdateCount + " !");
}
//解决 id{}: ["1' OR 1='1'))--"] 绕过id{}限制
//new ArrayList<Long>(idIn) 不能检查类型,Java泛型擦除问题,居然能把 ["a"] 赋值进去还不报错
for (int i = 0; i < idIn.size(); i++) {
Object o = idIn.get(i);
if (o == null) {
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !");
}
if (o instanceof Number) {
//解决 Windows mysql-5.6.26-winx64 等低于 5.7 的 MySQL 可能 id{}: [0] 生成 id IN(0) 触发 MySQL bug 导致忽略 IN 条件
//例如 UPDATE `apijson`.`TestRecord` SET `testAccountId` = -1 WHERE ( (`id` IN (0)) AND (`userId`= 82001) )
if (((Number) o).longValue() <= 0) {
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !");
}
}
else if (o instanceof String) {
if (StringUtil.isEmpty(o, true)) {
throw new IllegalArgumentException(method + "请求," + name + "/" + key
+ " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !");
}
}
else {
throw new IllegalArgumentException(method + "请求," + name + "/" + keyView on GitHub (pinned to 5284052872)
Solutions
- Filter falsy entries before sending: ids.filter(id => id != null)
- Fix the upstream data source that produced null ids
- Validate with a shared helper before every write request
Example fix
// before
{"User":{"id{}":[1,null,3]}}
// after
{"User":{"id{}":[1,3]}} Defensive patterns
Strategy: validation
Validate before calling
const cleanIds = (ids) => ids.filter(id => id !== null && id !== undefined);
Prevention
- Always filter null/undefined out of id lists before sending
- Avoid sparse arrays and unset List slots when building payloads
When it happens
Trigger: PUT/DELETE with {"User":{"id{}":[1,null,3]}} — any null element triggers this exact branch.
Common situations: Building the array with array.push(maybeMissingField) in JS; Java List with unset slots; JSON created from sparse data containing nulls.
Related errors
- 批量新增/修改失败!{}/{}:value 中value不合法!类型必须是 OBJECT ,结构为 {} !
- {method}请求,{name}/{key} 里面的 {idInKey}:value 中value的类型只能是 [Lo
- {method}请求,{name}/{key} 里面的 {idInKey}:[] 中所有项的类型都只能是 Long 或
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/4416a9f361dbf656.
Report an issue: GitHub.