{"record":{"id":"4416a9f361dbf656","repo":"Tencent/APIJSON","slug":"method-name-key-idinkey-4416a9","errorCode":null,"errorMessage":"{method}请求，{name}/{key} 里面的 {idInKey}:[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 ！","messagePattern":"(.+?)请求，(.+?)/(.+?) 里面的 (.+?):\\[\\] 中所有项都不能为 \\[ null, <= 0 的数字, 空字符串 \"\" \\] 中任何一个 ！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java","lineNumber":781,"sourceCode":"\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t+ \" 里面的 \" + idInKey + \":value 中value的类型只能是 [Long] ！\");\n\t\t}\n\t\tif (idIn == null) {\n\t\t\tif (atLeastOne && id == null && idRefInKey == null) {\n\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t+ \" 里面 \" + idKey + \",\" + idInKey  + \",\" + (idKey + \"{}@\") + \" 至少传其中一个！\");\n\t\t\t}\n\t\t} else {\n\t\t\tif (idIn.size() > maxUpdateCount) { //不允许一次操作 maxUpdateCount 条以上记录\n\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t+ \" 里面的 \" + idInKey + \":[] 中[]的长度不能超过 \" + maxUpdateCount + \" ！\");\n\t\t\t}\n\t\t\t//解决 id{}: [\"1' OR 1='1'))--\"] 绕过id{}限制\n\t\t\t//new ArrayList<Long>(idIn) 不能检查类型，Java泛型擦除问题，居然能把 [\"a\"] 赋值进去还不报错\n\t\t\tfor (int i = 0; i < idIn.size(); i++) {\n\t\t\t\tObject o = idIn.get(i);\n\t\t\t\tif (o == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t\t+ \" 里面的 \" + idInKey + \":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \\\"\\\" ] 中任何一个 ！\");\n\t\t\t\t}\n\t\t\t\tif (o instanceof Number) {\n\t\t\t\t\t//解决 Windows mysql-5.6.26-winx64 等低于 5.7 的 MySQL 可能 id{}: [0] 生成 id IN(0) 触发 MySQL bug 导致忽略 IN 条件\n\t\t\t\t\t//例如 UPDATE `apijson`.`TestRecord` SET `testAccountId` = -1 WHERE ( (`id` IN (0)) AND (`userId`= 82001) )\n\t\t\t\t\tif (((Number) o).longValue() <= 0) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t\t\t+ \" 里面的 \" + idInKey + \":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \\\"\\\" ] 中任何一个 ！\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (o instanceof String) {\n\t\t\t\t\tif (StringUtil.isEmpty(o, true)) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key\n\t\t\t\t\t\t\t\t+ \" 里面的 \" + idInKey + \":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \\\"\\\" ] 中任何一个 ！\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new IllegalArgumentException(method + \"请求，\" + name + \"/\" + key","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractVerifier.java#L763-L799","documentation":"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.","triggerScenarios":"PUT/DELETE with {\"User\":{\"id{}\":[1,null,3]}} — any null element triggers this exact branch.","commonSituations":"Building the array with array.push(maybeMissingField) in JS; Java List with unset slots; JSON created from sparse data containing nulls.","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"],"exampleFix":"// before\n{\"User\":{\"id{}\":[1,null,3]}}\n// after\n{\"User\":{\"id{}\":[1,3]}}","handlingStrategy":"validation","validationCode":"const cleanIds = (ids) => ids.filter(id => id !== null && id !== undefined);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always filter null/undefined out of id lists before sending","Avoid sparse arrays and unset List slots when building payloads"],"tags":["apijson","validation","null-handling","batch"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}