Tencent/APIJSON · error · IllegalArgumentException

{}:{ @combine:'{}' } 中字符 '{}' 不合法!逻辑连接符 & 右边缺少一个空格 !逻辑连接符 &

Error message

{}:{ @combine:'{}' } 中字符 '{}' 不合法!逻辑连接符 & 右边缺少一个空格 !逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!不允许首尾有空格,也不允许连续空格!左括号 ( 的右边 和 右括号 ) 的左边 都不允许有相邻空格!

What it means

In @combine parsing, '&' is only treated as a logic operator when the previous char was a space (last == ' '); the operator form additionally requires the next char to be a space. If '&' follows its leading space but is not followed by exactly one space (end of string or non-space next), this error is thrown — the '&' operator must have one adjacent space on BOTH sides.

Source

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

						result += "( " + gainCondition(isNot, wi) + " )";
						isNot = false;
						first = false;
					}

					key = "";
					lastLogic = 0;

					if (isOver) {
						break;
					}
				}

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

						result += SQL.AND;
						lastLogic = c;
						i ++;
					}
					else {
						key += c;
					}
				}
				else if (c == '|') {
					if (last == ' ') {
						if (i >= n - 1 || s.charAt(i + 1) != ' ') {
							throw new IllegalArgumentException(table + ":{ @combine: '" + combine
									+ "' } 中字符 '" + (i >= n - 1 ? s : s.substring(0, i + 1))
									+ "' 不合法!逻辑连接符 | 右边缺少一个空格 !逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!"

View on GitHub (pinned to 5284052872)

Solutions

  1. Format every operator as ' & ' — exactly one space before and after: "id & name".
  2. Build expressions with a helper that always joins with ' & ' / ' | ' (see validation code).
  3. Run a grammar pre-check before sending (see validation code).

Example fix

// before
{"@combine":"id &name"}
// after
{"@combine":"id & name"}
Defensive patterns

Strategy: validation

Validate before calling

if (!combine.matches("(\\S+|\\([^()]*\\))(\\s[&|]\\s(\\S+|\\([^()]*\\)))*"))
    throw new IllegalArgumentException("@combine must use exactly one space around each & and |");

Type guard

const WELL_SPACED = /^(?:\S+|\([^()]*\))(?:\s[&|]\s(?:\S+|\([^()]*\)))*$/;
function isWellSpaced(combine: string): boolean { return WELL_SPACED.test(combine); }

Prevention

When it happens

Trigger: @combine:"id &name", "id &", or "id & name" variants where after '&' comes end-of-string or a non-space char. (The double-space case is separately caught as an empty-key error.) Trigger point: line 3549, when s.charAt(i+1) != ' ' or i >= n-1.

Common situations: Hand-typing expressions with one space around the operator; concatenating "a " + "& " + "b" incorrectly (yielding "a & b" vs "a &b"); minifying JSON and stripping spaces inside the @combine string value by accident.

Related errors


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