Tencent/APIJSON · error · IllegalArgumentException

子查询 {}/{}:{ from:value } 中 value 对应的主表对象 {}:{} 不存在!

Error message

子查询 {}/{}:{ from:value } 中 value 对应的主表对象 {}:{} 不存在!

What it means

After structuring a 'key{}@' subquery, the parser resolves the main table object designated by 'from'. If 'from' is provided and the object JSON.get(obj, from) is null — or 'from' was omitted and no entry inside the subquery object is a Map with a table key — this IllegalArgumentException fires, reporting the unresolved 'from' value.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java:452

				String from = getString(subquery, apijson.JSONRequest.KEY_SUBQUERY_FROM);
				boolean isEmpty = StringUtil.isEmpty(from);
				M arrObj = isEmpty ? null : JSON.get(obj, from);
				if (isEmpty) {
					Set<Entry<String, Object>> set = obj.entrySet();
					for (Entry<String, Object> e : set) {
						String k = e == null ? null : e.getKey();
						Object v = k == null ? null : e.getValue();
						if (v instanceof Map<?, ?> && JSONMap.isTableKey(k)) {
							from = k;
							arrObj = (M) v;
							break;
						}
					}
				}

				if (arrObj == null) {
					throw new IllegalArgumentException("子查询 " + path + "/"
                            + key + ":{ from:value } 中 value 对应的主表对象 " + from + ":{} 不存在!");
				}

				SQLConfig<T, M, L> cfg = (SQLConfig) arrObj.get(AbstractParser.KEY_CONFIG);
				if (cfg == null) {
					throw new NotExistException(TAG + ".onParse  cfg == null");
				}

				Subquery s = new Subquery();
				s.setPath(path);
				s.setOriginKey(key);
				s.setOriginValue(subquery);

				s.setFrom(from);
				s.setRange(range);
				s.setKey(replaceKey);
				s.setConfig(cfg);

View on GitHub (pinned to 5284052872)

Solutions

  1. Set 'from' to exactly the table key used inside the subquery object (case-sensitive, no alias).
  2. Double-check spelling/case: "from": "Comment" must match the key "Comment": {...}.
  3. If 'from' is omitted, ensure at least one entry in the subquery object is a table-keyed JSONObject.

Example fix

// before
"id{}@": { "from": "Comment", "comment": { "@column": "userId" } }
// after
"id{}@": { "from": "Comment", "Comment": { "@column": "userId" } }
Defensive patterns

Strategy: validation

Validate before calling

String from = (String) subquery.get("from");
boolean found = from == null || subquery.containsKey(from) && subquery.get(from) instanceof Map;
if (!found) throw new IllegalArgumentException("from must name a table object inside the subquery");

Type guard

function fromResolves(sub: Record<string, unknown>): boolean {
  const f = sub.from;
  return f == null || (typeof f === 'string' && sub[f] != null && typeof sub[f] === 'object' && !Array.isArray(sub[f]));
}

Prevention

When it happens

Trigger: "id{}@": { "from": "Comment", "Post": { ... } } (from names a table not present), or { "from": "comment", ... } (wrong case / alias mismatch), or an object whose entries are all non-table keys.

Common situations: Renaming a table in the subquery but not updating 'from'; case mismatch between 'from' and the actual table key; using an alias ('Comment c') as the from value; forgetting the table object entirely.

Related errors


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