Tencent/APIJSON · error · IllegalArgumentException

{}:{ @combine:'{}' } 中字符 '{}' 不合法!左括号 ( 比 右括号 ) 多!数量必须相等从而完整

Error message

{}:{ @combine:'{}' } 中字符 '{}' 不合法!左括号 ( 比 右括号 ) 多!数量必须相等从而完整闭合 (...) !

What it means

Thrown after the @combine parse loop finishes: if depth != 0 there are more '(' than ')'. The whole string is reported because the imbalance is only detectable at end-of-input. Without balanced parentheses the library cannot generate a valid WHERE clause, so it rejects the request.

Source

Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java:3649

					depth --;
					if (depth < 0) {
						throw new IllegalArgumentException(errPrefix + " 中字符 '" + s.substring(0, i + 1)
						+ "' 不合法!左括号 ( 比 右括号 ) 少!数量必须相等从而完整闭合 (...) !");
					}

					result += c;
					lastLogic = 0;
				}
				else {
					key += c;
				}

				last = c;
				i ++;
			}

			if (depth != 0) {
				throw new IllegalArgumentException(errPrefix + " 中字符 '" + s
						+ "' 不合法!左括号 ( 比 右括号 ) 多!数量必须相等从而完整闭合 (...) !");
			}
		}

		List<Object> exprPreparedValues = getPreparedValueList();
		if (isHaving == false) {  // 只收集 AND 条件值
			setPreparedValueList(new ArrayList<>());
		}

		Set<Entry<String, Object>> set = conditionMap.entrySet();

		String andCond = "";
		boolean isItemFirst = true;

		for (Entry<String, Object> entry : set) {
			String key = entry == null ? null : entry.getKey();
			if (key == null || usedKeyCountMap.containsKey(key)) {
				continue;

View on GitHub (pinned to 5284052872)

Solutions

  1. Count '(' and ')' in the @combine value and make them equal, closing every opened group.
  2. Regenerate the expression with a builder that always emits matched pairs.
  3. Re-test with a trivial "(a & b)" first, then add groups back one at a time.

Example fix

// before
{"@combine": "(a & b | (c & d)"}
// after
{"@combine": "(a & b) | (c & d)"}
Defensive patterns

Strategy: validation

Validate before calling

function balanced(s) { let d = 0; for (const c of s) { if (c === '(') d++; if (c === ')') d--; } return d === 0; }

Prevention

When it happens

Trigger: @combine values like "(a & b" or "((a | b) & c" — an unclosed group at the end of the expression.

Common situations: Truncated strings (request size limits, copy-paste), client-side templating that omits the tail ')', or edits made to a previously working combine string.

Related errors


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