Tencent/APIJSON · error · UnsupportedOperationException
字符串 {suffix} 不合法!预编译模式下 {key}:"column?value;function(arg0,ar
Error message
字符串 {suffix} 不合法!预编译模式下 {key}:"column?value;function(arg0,arg1,...)?value..." 中 ?value 必须符合正则表达式 {PATTERN_RANGE} 且不包含连续减号 -- 或注释符 /* !不允许多余的空格! What it means
For expressions with functions, the suffix after ')' (and before the ':' alias separator) must be empty or match PATTERN_RANGE (only digits and the operators % , ! = < > / . + - * ^) and must not contain '--' or '/*'. Anything else — letters, spaces, parentheses — throws this UnsupportedOperationException, because suffixes are restricted to numeric comparison tails like '>1' or '%5<=3'.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java:2595
// 解析函数内的参数
String ckeys[] = parseArgsSplitWithComma(s, false, containRaw, allowAlias);
String suffix = expression.substring(end + 1); //:contactCount
String alias = null;
if (allowAlias) {
int index = suffix.lastIndexOf(":");
alias = index < 0 ? "" : suffix.substring(index + 1); //contactCount
suffix = index < 0 ? suffix : suffix.substring(0, index);
if (alias.isEmpty() == false && StringUtil.isName(alias) == false) {
throw new IllegalArgumentException("字符串 " + alias + " 不合法!预编译模式下 "
+ key + ":value 中 value里面用 ; 分割的每一项"
+ " function(arg0,arg1,...):alias 中 alias 必须是1个单词!并且不要有多余的空格!");
}
}
if (suffix.isEmpty() == false && (suffix.contains("--") || suffix.contains("/*")
|| PATTERN_RANGE.matcher(suffix).matches() == false)) {
throw new UnsupportedOperationException("字符串 " + suffix + " 不合法!预编译模式下 " + key
+ ":\"column?value;function(arg0,arg1,...)?value...\""
+ " 中 ?value 必须符合正则表达式 " + PATTERN_RANGE + " 且不包含连续减号 -- 或注释符 /* !不允许多余的空格!");
}
String origin = fun + "(" + (distinct ? PREFIX_DISTINCT : "") + StringUtil.get(ckeys) + ")" + suffix;
expression = origin + (StringUtil.isEmpty(alias, true) ? "" : gainAs() + quote + alias + quote);
}
else {
//是窗口函数 fun(arg0,agr1) OVER (agr0 agr1 ...)
int keyIndex = containOver ? overIndex : againstIndex;
String s1 = expression.substring(0, keyIndex + 1); // OVER 前半部分
String s2 = expression.substring(keyIndex + 1); // OVER 后半部分
int index1 = s1.indexOf("("); // 函数 "(" 的起始位置
int end = s2.lastIndexOf(")"); // 后半部分 “)” 的位置
if (index1 >= end + s1.length()) {
throw new IllegalArgumentException("字符 " + expression + " 不合法!"View on GitHub (pinned to 5284052872)
Solutions
- Keep the suffix to comparison operators and digits only, e.g. "sum(id)>1", "max(id)%5<=3", or remove it.
- Strip whitespace from the expression before sending.
- Never include -- or /*; they are treated as comment injection.
- Move complex conditions to the proper key (e.g. @having) or a @raw entry.
Example fix
// before
{"User":{"@column":"sum(id) > 10 "}}
// after
{"User":{"@column":"sum(id)>10"}} Defensive patterns
Strategy: validation
Validate before calling
const RANGE=/^[0-9%,!=<>/\.\+\-\*\^]+$/;
const tail=expr.slice(expr.lastIndexOf(')')+1).split(':')[0];
if(tail && (tail.includes('--')||tail.includes('/*')||!RANGE.test(tail)))throw new Error('bad suffix'); Type guard
null
Try / catch
catch UnsupportedOperationException; strip suffix or move condition to @having/@raw and retry
Prevention
- Suffix = operators+digits only
- No keywords or spaces after ')'
- Treat -- and /* as forbidden input everywhere
When it happens
Trigger: "@column":"sum(id)>10 " (trailing space), "@column":"count(id) and 1=1" (letters), "@column":"sum(id)--" (comment marker), "@column":"max(id)/*x*/" — all fail the range pattern or comment check.
Common situations: Porting WHERE-style conditions into @column suffixes; SQL-injection probes containing -- or /*; accidentally leaving trailing whitespace or newlines in generated expressions; using BETWEEN/AND keywords in the suffix.
Related errors
- 字符 {fun} 不合法!预编译模式下 {example} 中 function 必须符合小写英文单词的 SQL 函数名
- 字符串 {ck} 不合法!预编译模式下 @column:"column0,column1:alias;function0
- HEAD请求: 字符 {alias} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的
- HEAD请求: 字符{origin} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的
- HEAD请求: 字符 {origin.substring(0, start)} 不合法!预编译模式下 @column:v
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/c70dbc79a212ed6a.
Report an issue: GitHub.