Tencent/APIJSON · error · IllegalArgumentException

${e.getKey()}:'/targetTable/targetKey' 中路径对应的 '${targetTable

Error message

${e.getKey()}:'/targetTable/targetKey' 中路径对应的 '${targetTableKey}':value 中 value 类型不合法!必须是 {} 这种 Map<String, Object> 格式!${e2.getMessage()}

What it means

The parser resolves the target table object of an ON reference via JSON.get(request, targetTableKey). If that lookup throws (path navigation through a non-object, e.g. an array or a String mid-path), the exception is wrapped in this IllegalArgumentException telling you the target ':value' is not a Map<String, Object>.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:1849

				}

				String targetAlias = targetEntry.getValue(); //owner
				if (StringUtil.isNotEmpty(targetAlias, true) && StringUtil.isName(targetAlias) == false) {
					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);

View on GitHub (pinned to 5284052872)

Solutions

  1. Reference the table object directly at the level where it is a Map: '/User/id', not '/User[]/User/id'
  2. Make sure every intermediate segment in the path is an object key, ending at the target table object

Example fix

// before
{ 'join': '</Comment', 'Comment': { 'userId@': '/User[]/User/id' } }
// after
{ 'join': '</Comment', 'Comment': { 'userId@': '/User/id' }, 'User': { 'id': 38710 } }
Defensive patterns

Strategy: type-guard

Validate before calling

function resolveTable(req, tableKey) {
  let cur = req;
  for (const seg of tableKey.split('/').filter(Boolean)) {
    if (cur == null || typeof cur !== 'object' || Array.isArray(cur)) return null;
    cur = cur[seg];
  }
  return cur && typeof cur === 'object' && !Array.isArray(cur) ? cur : null;
}
function checkRefTablesAreObjects(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;
        if (resolveTable(req, v.split('/').slice(1, -1).join('/')) == null) {
          return `${k}: '${v}' does not lead to an object`;
        }
      }
    }
  }
  return null;
}

Type guard

const isPlainObject = (v) => v != null && typeof v === 'object' && !Array.isArray(v);

Try / catch

Catch IllegalArgumentException with '必须是 {} 这种 Map<String, Object> 格式'; rewrite the path to address the table object directly.

Prevention

When it happens

Trigger: 'userId@': '/User[]/User/id' where 'User[]' is a List (cannot be navigated as object); '/User:name/id' where 'name' is a plain String; paths whose intermediate segments hit non-object values.

Common situations: Referencing a table inside an array by its wrapper key; deep paths copied from response JSON rather than request structure; intermediate segment collides with a plain column name.

Related errors


AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14). Data as JSON: /api/errors/756b1cdc87a45707. Report an issue: GitHub.