Tencent/APIJSON · error · Exception
服务器内部错误,解析子查询 {}/{}:{ } 为 Subquery 对象失败!
Error message
服务器内部错误,解析子查询 {}/{}:{ } 为 Subquery 对象失败! What it means
Internal parser failure: for a 'key{}@' subquery, the parser runs the subquery object through onArrayParse and expects a non-empty array whose first element is a JSONObject. If the result array is null/empty or its first element is null, a generic Exception '服务器内部错误...' is thrown. It usually indicates the subquery object could not be structured into a table config at all (malformed inner object rather than a bad field).
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java:432
@Override
public boolean onParse(@NotNull String key, @NotNull Object value) throws Exception {
if (key.endsWith("@")) { // StringUtil.isPath((String) value)) {
// [] 内主表 position > 0 时,用来生成 SQLConfig<T, M, L> 的键值对全都忽略,不解析
if (value instanceof Map<?, ?>) { // key{}@ getRealKey, SQL 子查询对象,JSONRequest -> SQLConfig.getSQL
String replaceKey = key.substring(0, key.length() - 1);
M subquery = (M) value;
String range = getString(subquery, KEY_SUBQUERY_RANGE);
if (range != null && SUBQUERY_RANGE_ALL.equals(range) == false && SUBQUERY_RANGE_ANY.equals(range) == false) {
throw new IllegalArgumentException("子查询 " + path + "/" + key + ":{ range:value } 中 value 只能为 ["
+ SUBQUERY_RANGE_ALL + ", " + SUBQUERY_RANGE_ANY + "] 中的一个!");
}
L arr = parser.onArrayParse(subquery, path, key, true, null);
M obj = arr == null || arr.isEmpty() ? null : JSON.get(arr, 0);
if (obj == null) {
throw new Exception("服务器内部错误,解析子查询 " + path + "/" + key + ":{ } 为 Subquery 对象失败!");
}
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;
}
}
}
View on GitHub (pinned to 5284052872)
Solutions
- Make sure the subquery object contains a well-formed main table object, e.g. "id{}@": { "from": "Comment", "Comment": { "@column": "userId" } }.
- Check that the 'from' value matches a table key actually present inside the subquery object.
- If it still fails, enable APIJSON logging to inspect what onArrayParse returned and simplify the subquery to the minimal from + table form.
Example fix
// before
"id{}@": { "from": "Comment", "range": "ANY" }
// after
"id{}@": { "from": "Comment", "range": "ANY", "Comment": { "@column": "userId" } } Defensive patterns
Strategy: try-catch
Validate before calling
// before sending: subquery object must contain a table object
boolean hasTableObj(JSONObject sub) {
return sub.entrySet().stream().anyMatch(e -> e.getValue() instanceof Map && JSONMap.isTableKey(e.getKey()));
} Type guard
function isWellFormedSubquery(sub: Record<string, unknown>): boolean {
return Object.entries(sub).some(([k, v]) => v !== null && typeof v === 'object' && !Array.isArray(v) && /^[A-Za-z][A-Za-z0-9_]*$/.test(k));
} Try / catch
try { parse(request); } catch (Exception e) { if (e.getMessage() != null && e.getMessage().contains("解析子查询")) { /* log subquery object, fix its structure */ } throw e; } Prevention
- Always include the main table object inside a 'key{}@' subquery.
- Match 'from' to a real table key in the same object.
- Test subqueries in isolation before embedding them in larger requests.
When it happens
Trigger: A 'key{}@' value that parses to no objects — e.g. {"from": "X"} with no table object inside, or an inner structure the array parser drops entirely (all keys filtered out), leaving arr empty so JSON.get(arr, 0) returns null.
Common situations: Subquery object missing its main table entry; inner table object consisting only of keys that get discarded during parsing; version changes in the array parser that alter which inner objects survive.
Related errors
- 子查询 {}/{}:{ range:value } 中 value 只能为 [ALL, ANY] 中的一个!
- 子查询 {}/{}:{ from:value } 中 value 对应的主表对象 {}:{} 不存在!
- 服务器内部错误,List<Join> 中 Join.onList[{}] = null!
- 服务器内部错误,List<Join> 中 Join.onList[{}].getOriginKey() = null!
- 服务器内部错误,List<Join> 中 Join.onList[0] = null!
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/fe617f179dab0ae4.
Report an issue: GitHub.