{"record":{"id":"7622bba767b6ef80","repo":"Tencent/APIJSON","slug":"e-getkey-value-value-targetpath","errorCode":null,"errorMessage":"${e.getKey()}:value 中 value 值 ${targetPath} 不合法！必须为引用赋值的路径 '/targetTable/targetKey' ！","messagePattern":"(.+?):value 中 value 值 (.+?) 不合法！必须为引用赋值的路径 '/targetTable/targetKey' ！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":1812,"sourceCode":"\n            if (whereJoinMap.containsKey(table)) {\n                Object rawOuter = whereJoinMap.get(table);\n                M outerObj1 = (M) JSON.createJSONObject((Map<String, Object>) rawOuter);\n                j.setOuter(outerObj1);\n            }\n\n\t\t\tif (arrKey != null) {\n\t\t\t\tInteger count = getInteger(parentPathObj, apijson.JSONRequest.KEY_COUNT);\n\t\t\t\tj.setCount(count == null ? getDefaultQueryCount() : count);\n\t\t\t}\n\n\t\t\tList<Join.On> onList = new ArrayList<>();\n\t\t\tfor (Entry<String, Object> refEntry : refSet) {\n\t\t\t\tString originKey = refEntry.getKey();\n\n\t\t\t\tString targetPath = (String) refEntry.getValue();\n\t\t\t\tif (StringUtil.isEmpty(targetPath, true)) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":value 中 value 值 \" + targetPath + \" 不合法！必须为引用赋值的路径 '/targetTable/targetKey' ！\");\n\t\t\t\t}\n\n\t\t\t\t// 取出引用赋值路径 targetPath 对应的 Table 和 key\n\t\t\t\tindex = targetPath.lastIndexOf(\"/\");\n\t\t\t\tString targetKey = index < 0 ? null : targetPath.substring(index + 1);\n\t\t\t\tif (StringUtil.isName(targetKey) == false) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable/targetKey' 中 targetKey 值 \" + targetKey + \" 不合法！必须满足英文单词变量名格式！\");\n\t\t\t\t}\n\n\t\t\t\ttargetPath = targetPath.substring(0, index);\n\t\t\t\tindex = targetPath.lastIndexOf(\"/\");\n\t\t\t\tString targetTableKey = index < 0 ? targetPath : targetPath.substring(index + 1);\n\n\t\t\t\t// 主表允许别名\n\t\t\t\tapijson.orm.Entry<String, String> targetEntry = Pair.parseEntry(targetTableKey, true);\n\t\t\t\tString targetTable = targetEntry.getKey(); //User\n\t\t\t\tif (StringUtil.isName(targetTable) == false) {\n\t\t\t\t\tthrow new IllegalArgumentException(e.getKey() + \":'/targetTable/targetKey' 中 targetTable 值 \" + targetTable + \" 不合法！必须满足大写字母开头的表对象英文单词 key 格式！\");","sourceCodeStart":1794,"sourceCodeEnd":1830,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L1794-L1830","documentation":"For each ON condition, the value of the 'key@' entry must be a non-empty reference path like '/targetTable/targetKey'. This IllegalArgumentException is thrown when that value is empty or whitespace-only (StringUtil.isEmpty(targetPath, true)).","triggerScenarios":"{ 'join': '</Moment', 'Moment': { 'userId@': '' } } or 'userId@': '   ' — the reference key exists but points at nothing.","commonSituations":"Building the request from a form/template where the reference field was left blank; stripping a value during sanitization; copy-paste of an unfinished example.","solutions":["Fill in the reference path: 'userId@': '/User/id'","Remove the empty key@ entry entirely if no join condition is intended (but note a join then needs '*' type or another ON key)"],"exampleFix":"// before\n{ 'join': '</Moment', 'Moment': { 'userId@': '' } }\n// after\n{ 'join': '</Moment', 'Moment': { 'userId@': '/User/id' }, 'User': { 'id': 38710 } }","handlingStrategy":"validation","validationCode":"function checkEmptyRefs(req) {\n  for (const [tblKey, tbl] of Object.entries(req)) {\n    if (tbl && typeof tbl === 'object') {\n      for (const [k, v] of Object.entries(tbl)) {\n        if (k.endsWith('@') && (v == null || String(v).trim() === '')) {\n          return `${tblKey}/${k} is empty; reference paths must look like '/Table/key'`;\n        }\n      }\n    }\n  }\n  return null;\n}","typeGuard":"const isNonEmptyRefPath = (v) => typeof v === 'string' && v.trim().length > 0 && v.startsWith('/');","tryCatchPattern":"Catch IllegalArgumentException with \"必须为引用赋值的路径\"; fill or strip the empty key@ entry.","preventionTips":["Reject empty/whitespace values in key@ fields at form-validation time","Treat blank reference fields as bugs in the request builder, not as optional"],"tags":["apijson","join","reference-assignment","empty-value"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}