Tencent/APIJSON · error · IllegalArgumentException

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

Error message

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

What it means

Thrown while parsing @combine when a ')' is encountered but depth is already 0 — i.e. there are more ')' than '('. The parser decrements depth on each ')' and rejects negative depth immediately because the expression cannot form a well-formed boolean condition.

Source

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

						throw new IllegalArgumentException(errPrefix + " 中字符 '" + s.substring(i)
						+ "' 不合法!左边缺少 & | 逻辑连接符!逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!"
						+ "不允许首尾有空格,也不允许连续空格!左括号 ( 的右边 和 右括号 ) 的左边 都不允许有相邻空格!");
					}

					depth ++;
					if (depth > maxDepth && maxDepth > 0) {
						throw new IllegalArgumentException(errPrefix + " 中字符 '" + s.substring(0, i + 1)
						+ "' 不合法!括号 (()) 嵌套层级 " + depth + " 已超过最大值,必须在 0-" + maxDepth + " 内!");
					}

					result += c;
					lastLogic = 0;
					first = true;
				}
				else if (c == ')') {
					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
						+ "' 不合法!左括号 ( 比 右括号 ) 多!数量必须相等从而完整闭合 (...) !");
			}

View on GitHub (pinned to 5284052872)

Solutions

  1. Balance the parentheses in @combine so every ')' has a matching earlier '('.
  2. If the string is generated by client code, add a stack/balance check before sending the request.
  3. Simplify the expression and rebuild it group by group.

Example fix

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

Strategy: validation

Validate before calling

function balanced(s) { let d = 0; for (const c of s) { if (c === '(') d++; if (c === ')') { d--; if (d < 0) return false; } } return d === 0; }
if (!balanced(combineStr)) throw new Error('unbalanced @combine');

Prevention

When it happens

Trigger: @combine values like "a) & b" or "(a & b))" — any expression where a closing parenthesis appears without a matching preceding '('.

Common situations: Hand-written or programmatically concatenated combine strings that drop or duplicate a parenthesis; UI query-builder bugs emitting unbalanced strings.

Related errors


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