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
- Set 'from' to exactly the table key used inside the subquery object (case-sensitive, no alias).
- Double-check spelling/case: "from": "Comment" must match the key "Comment": {...}.
- 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
- Keep 'from' identical (case-sensitive) to the table key inside the subquery.
- Update 'from' whenever you rename the inner table key.
- Don't use aliases in 'from'; use the plain table name.
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
- 子查询 {}/{}:{ range:value } 中 value 只能为 [ALL, ANY] 中的一个!
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
- {}/{}:value 中 value 必须为 依赖路径String 或 SQL子查询JSONObject !
- {}/{}:value 中 value 必须为函数String!
- {}/{}:{} 不合法!数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arra
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/a431f9df50db80fb.
Report an issue: GitHub.