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

  1. Fix the reference: "key@": "@/Table/alias/column" must point to a table and alias that exist in the same request.
  2. If '@' was not intended as a reference, rename the key so it does not end with '@'.
  3. 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

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


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