Tencent/APIJSON · error · IllegalArgumentException
${e.getKey()}:'/targetTable/targetKey' 中路径对应的对象 '${targetTab
Error message
${e.getKey()}:'/targetTable/targetKey' 中路径对应的对象 '${targetTableKey}':{} 不存在或值为 null !必须是 {} 这种 Map<String, Object> 格式! What it means
After resolving the ON reference path, JSON.get(request, targetTableKey) returned null: the referenced table object is absent from (or null in) the current request. An ON condition must point at a real table object in the same request, so an IllegalArgumentException is thrown.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:1853
throw new IllegalArgumentException(e.getKey() + ":'/targetTable:targetAlias/targetKey' 中 targetAlias 值 " + targetAlias + " 不合法!必须满足英文单词变量名格式!");
}
//targetTable = targetTableKey; // 主表允许别名
if (StringUtil.isName(targetTable) == false) {
throw new IllegalArgumentException(e.getKey() + ":'/targetTable/targetKey' 中 targetTable 值 " + targetTable + " 不合法!必须满足大写字母开头的表对象英文单词 key 格式!");
}
//对引用的JSONObject添加条件
Map<String, Object> targetObj;
try {
targetObj = JSON.get(request, targetTableKey);
}
catch (Exception e2) {
throw new IllegalArgumentException(e.getKey() + ":'/targetTable/targetKey' 中路径对应的 '" + targetTableKey + "':value 中 value 类型不合法!必须是 {} 这种 Map<String, Object> 格式!" + e2.getMessage());
}
if (targetObj == null) {
throw new IllegalArgumentException(e.getKey() + ":'/targetTable/targetKey' 中路径对应的对象 '" + targetTableKey + "':{} 不存在或值为 null !必须是 {} 这种 Map<String, Object> 格式!");
}
Join.On on = new Join.On();
on.setKeyAndType(j.getJoinType(), j.getTable(), originKey);
if (StringUtil.isName(on.getKey()) == false) {
throw new IllegalArgumentException(apijson.JSONRequest.KEY_JOIN + ":value 中 value 的 key@ 中 key 值 " + on.getKey() + " 不合法!必须满足英文单词变量名格式!");
}
on.setOriginKey(originKey);
on.setOriginValue((String) refEntry.getValue());
on.setTargetTableKey(targetTableKey);
on.setTargetTable(targetTable);
on.setTargetAlias(targetAlias);
on.setTargetKey(targetKey);
onList.add(on);
}
View on GitHub (pinned to 5284052872)
Solutions
- Add the referenced table object to the same request: 'User': { 'id': 38710 }
- Ensure it is a real object, not null, and its key (including alias) matches the reference path exactly
Example fix
// before
{ 'join': '</Comment', 'Comment': { 'userId@': '/User/id' } }
// after
{ 'join': '</Comment', 'Comment': { 'userId@': '/User/id' }, 'User': { 'id': 38710 } } Defensive patterns
Strategy: validation
Validate before calling
function checkTargetsExist(req) {
for (const tbl of Object.values(req)) {
if (tbl && typeof tbl === 'object') {
for (const [k, v] of Object.entries(tbl)) {
if (!k.endsWith('@') || typeof v !== 'string' || !v.startsWith('/')) continue;
const targetKey = v.split('/')[1]; // Table or Table:alias
if (req[targetKey.split(':')[0]] == null) {
return `${k}: target object '${targetKey}' missing in request`;
}
}
}
}
return null;
} Try / catch
Catch IllegalArgumentException with '不存在或值为 null'; add the referenced table object to the request and retry once.
Prevention
- Every ON path target must be declared in the same request payload
- Watch alias consistency: '/User:owner/id' requires the owner-aliased object
When it happens
Trigger: { 'join': '</Comment', 'Comment': { 'userId@': '/User/id' } } without a 'User' object; or 'User': null; or referencing 'User:owner' when the request only declares a differently keyed object.
Common situations: Forgetting the main table object when hand-writing a join request; client code conditionally omitting the referenced table; alias mismatch between the path ('/User:owner/id') and the declared table key.
Related errors
- join:${e.getKey()} 中 ${key} 不合法!必须为 &/Table0,</Table1/key1,@
- join:${e.getKey()}' 对应的 ${tableKey}:{ ${key}: value } 中 valu
- ${table}/${k} 不合法!join 关联的 Table 中,join: ?/Table/key 时只能有 1
- ${e.getKey()}:value 中 value 值 ${targetPath} 不合法!必须为引用赋值的路径 '
- AbstractParser.onJoinParse join 只能是 String 或 Map<String, Ob
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/e93904c702bfddf6.
Report an issue: GitHub.