Tencent/APIJSON · error · IllegalArgumentException

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

Error message

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

What it means

Identical rule to error 155 but for '|': when '|' follows a leading space (operator position) but is not followed by exactly one space — next char is not ' ' or the operator is at end of string — the expression violates the single-space-around-operator grammar and is rejected.

Source

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

					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))
									+ "' 不合法!逻辑连接符 | 右边缺少一个空格 !逻辑连接符 & | 左右必须各一个相邻空格!空格不能多也不能少!"
									+ "不允许首尾有空格,也不允许连续空格!左括号 ( 右边和右括号 ) 左边都不允许有相邻空格!");
						}

						result += SQL.OR;
						lastLogic = c;
						i ++;
					}
					else {
						key += c;
					}
				}
				else if (c == '!') {
					last = i <= 0 ? 0 : s.charAt(i - 1);  // & | 后面跳过了空格

					char next = i >= n - 1 ? 0 : s.charAt(i + 1);
					if (last == ' ' || last == '(') {

View on GitHub (pinned to 5284052872)

Solutions

  1. Write ' | ' with exactly one space on each side: "a | (b | c)".
  2. Use the programmatic join helper / pre-validation regex before sending.
  3. Never place '(' immediately after '&' or ')' immediately before them — spaces around operators only, none adjacent to parentheses.

Example fix

// before
{"@combine":"id |(name | tag)"}
// after
{"@combine":"id | (name | tag)"}
Defensive patterns

Strategy: validation

Validate before calling

// same grammar as '&' — one space on both sides of '|'
if (!combine.matches("(\\S+|\\([^()]*\\))(\\s[&|]\\s(\\S+|\\([^()]*\\)))*"))
    throw new IllegalArgumentException("@combine must use exactly one space around each & and |");

Type guard

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

Prevention

When it happens

Trigger: @combine:"id |name", "id |", "(a|b)" won't reach here (no spaces) but "a |(b)" will: after '|' comes '(' not ' '. Trigger at line 3565. Note this error's message uses table+combine directly rather than errPrefix, but the meaning is the same.

Common situations: Same as 155: single-sided spacing around OR operators; "a |(b | c)" style grouping where '(' directly follows the operator.

Related errors


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