Tencent/APIJSON · error · IllegalArgumentException
AbstractSQLConfig.getWhereItem: 字符 {} 不合法!
Error message
AbstractSQLConfig.getWhereItem: 字符 {} 不合法! What it means
Thrown by gainWhereItem when a condition key ends with '@'. Trailing '@' marks a reference (e.g. "id@": "@/User/id") and such keys must be resolved earlier by the parser, not passed through as a plain WHERE item; reaching this branch means the reference was left unresolved/malformed.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java:3957
/**
* @param key
* @param value
* @param method
* @param verifyName
* @return
* @throws Exception
*/
protected String gainWhereItem(String key, Object value, RequestMethod method, boolean verifyName) throws Exception {
Log.d(TAG, "getWhereItem key = " + key);
// 避免筛选到全部 value = key == null ? null : where.get(key);
if (key == null || key.endsWith("()") || key.startsWith("@")) { //关键字||方法, +或-直接报错
Log.d(TAG, "getWhereItem key == null || key.endsWith(()) || key.startsWith(@) >> continue;");
return null;
}
if (key.endsWith("@")) { // 引用
// key = key.substring(0, key.lastIndexOf("@"));
throw new IllegalArgumentException(TAG + ".getWhereItem: 字符 " + key + " 不合法!");
}
if (value == null) {
return null;
}
int keyType;
if (key.endsWith("$")) {
keyType = 1;
}
else if (key.endsWith("~")) {
keyType = key.charAt(key.length() - 2) == '*' ? -2 : 2; //FIXME StringIndexOutOfBoundsException
}
else if (key.endsWith("%")) {
keyType = 3;
}
else if (key.endsWith("{}")) {
keyType = 4;View on GitHub (pinned to 5284052872)
Solutions
- Fix the reference: "key@": "@/Table/alias/column" must point to a table and alias that exist in the same request.
- If '@' was not intended as a reference, rename the key so it does not end with '@'.
- Ensure the referenced table is inside the same request object graph, not a separate request.
Example fix
// before
{"User": {"id@": "@/Comment/userIdx"}, "Comment": {...}}
// after
{"User": {"id@": "@/Comment/userId"}, "Comment": {...}} Defensive patterns
Strategy: validation
Validate before calling
for (const key of Object.keys(tableObj)) {
if (key.endsWith('@')) {
const ref = tableObj[key]; // must be '@/Table/alias/col'
if (!/^\/@?\w+(\/\w+){1,2}$/.test(ref)) throw new Error('bad reference ' + key);
}
} Prevention
- Validate '@/Table/alias/column' reference paths client-side.
- Never use '@' as the last character of a normal column key.
When it happens
Trigger: Sending a condition like {"User": {"myCol@": "@/other/id"}} where the reference path is invalid or the parser could not associate it, leaving the raw key to fall into normal WHERE-item processing.
Common situations: Typos in reference paths, referencing a table/alias not present in the same request, or using '@' suffix accidentally as part of a column name.
Related errors
- {}/{}:value 中 value 必须为 依赖路径String 或 SQL子查询JSONObject !
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/2a0892d71ddf6bc5.
Report an issue: GitHub.