{"record":{"id":"e93904c702bfddf6","repo":"Tencent/APIJSON","slug":"e-getkey-targettable-targetkey","errorCode":null,"errorMessage":"${e.getKey()}:'/targetTable/targetKey' 中路径对应的对象 '${targetTableKey}':{} 不存在或值为 null ！必须是 {} 这种 Map<String, Object> 格式！","messagePattern":"(.+?):'/targetTable/targetKey' 中路径对应的对象 '(.+?)':(.+?) 不存在或值为 null ！必须是 (.+?) 这种 Map<String, Object> 格式！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":1853,"sourceCode":"\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable:targetAlias/targetKey' 中 targetAlias 值 \" + targetAlias + \" 不合法！必须满足英文单词变量名格式！\");\n\t\t\t\t}\n\n\t\t\t\t//targetTable = targetTableKey;  // 主表允许别名\n\t\t\t\tif (StringUtil.isName(targetTable) == false) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable/targetKey' 中 targetTable 值 \" + targetTable + \" 不合法！必须满足大写字母开头的表对象英文单词 key 格式！\");\n\t\t\t\t}\n\n\t\t\t\t//对引用的JSONObject添加条件\n\t\t\t\tMap<String, Object> targetObj;\n\t\t\t\ttry {\n\t\t\t\t\ttargetObj = JSON.get(request, targetTableKey);\n\t\t\t\t}\n\t\t\t\tcatch (Exception e2) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable/targetKey' 中路径对应的 '\" + targetTableKey + \"':value 中 value 类型不合法！必须是 {} 这种 Map<String, Object> 格式！\" + e2.getMessage());\n\t\t\t\t}\n\n\t\t\t\tif (targetObj == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable/targetKey' 中路径对应的对象 '\" + targetTableKey + \"':{} 不存在或值为 null ！必须是 {} 这种 Map<String, Object> 格式！\");\n\t\t\t\t}\n\n\t\t\t\tJoin.On on = new Join.On();\n\t\t\t\ton.setKeyAndType(j.getJoinType(), j.getTable(), originKey);\n\t\t\t\tif (StringUtil.isName(on.getKey()) == false) {\n\t\t\t\t\tthrow new IllegalArgumentException(apijson.JSONRequest.KEY_JOIN + \":value 中 value 的 key@ 中 key 值 \" + on.getKey() + \" 不合法！必须满足英文单词变量名格式！\");\n\t\t\t\t}\n\n\t\t\t\ton.setOriginKey(originKey);\n\t\t\t\ton.setOriginValue((String) refEntry.getValue());\n\t\t\t\ton.setTargetTableKey(targetTableKey);\n\t\t\t\ton.setTargetTable(targetTable);\n\t\t\t\ton.setTargetAlias(targetAlias);\n\t\t\t\ton.setTargetKey(targetKey);\n\n\t\t\t\tonList.add(on);\n\t\t\t}\n","sourceCodeStart":1835,"sourceCodeEnd":1871,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L1835-L1871","documentation":"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.","triggerScenarios":"{ '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.","commonSituations":"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.","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"],"exampleFix":"// before\n{ 'join': '</Comment', 'Comment': { 'userId@': '/User/id' } }\n// after\n{ 'join': '</Comment', 'Comment': { 'userId@': '/User/id' }, 'User': { 'id': 38710 } }","handlingStrategy":"validation","validationCode":"function checkTargetsExist(req) {\n  for (const tbl of Object.values(req)) {\n    if (tbl && typeof tbl === 'object') {\n      for (const [k, v] of Object.entries(tbl)) {\n        if (!k.endsWith('@') || typeof v !== 'string' || !v.startsWith('/')) continue;\n        const targetKey = v.split('/')[1]; // Table or Table:alias\n        if (req[targetKey.split(':')[0]] == null) {\n          return `${k}: target object '${targetKey}' missing in request`;\n        }\n      }\n    }\n  }\n  return null;\n}","typeGuard":null,"tryCatchPattern":"Catch IllegalArgumentException with '不存在或值为 null'; add the referenced table object to the request and retry once.","preventionTips":["Every ON path target must be declared in the same request payload","Watch alias consistency: '/User:owner/id' requires the owner-aliased object"],"tags":["apijson","join","missing-object","reference-assignment"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}