Tencent/APIJSON · error · IllegalArgumentException
字符 {ck} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项 column:
Error message
字符 {ck} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项 column:alias 中 column 必须是1个单词!如果有alias,则alias也必须为1个单词!关键字必须全大写,且以空格分隔的参数,空格必须只有 1 个!其它情况不允许空格! What it means
In parseArgsSplitWithComma with isColumn=true and allowAlias=true under prepared mode, every comma-separated item split at ':' must yield a single-word origin and (if present) a single-word alias. Spaces around ':', multi-word tokens, or SQL keywords mixed into column items all fail StringUtil.isName and throw this IllegalArgumentException — the message also notes keywords must be UPPERCASE with exactly one space for space-separated args.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java:2730
// 参数不包含",",即不是字符串
// 解析参数:1. 字段 ,2. 是以空格分隔的参数 eg: cast(now() as date)
if ("=null".equals(ck)) {
origin = SQL.isNull();
}
else if ("!=null".equals(ck)) {
origin = SQL.isNull(false);
}
else {
origin = ck;
alias = null;
if (allowAlias) {
int index = isColumn ? ck.lastIndexOf(":") : -1; //StringUtil.split返回数组中,子项不会有null
origin = index < 0 ? ck : ck.substring(0, index); //获取 : 之前的
alias = index < 0 ? null : ck.substring(index + 1);
if (isPrepared()) {
if (isColumn) {
if (StringUtil.isName(origin) == false || (alias != null && StringUtil.isName(alias) == false)) {
throw new IllegalArgumentException("字符 " + ck + " 不合法!"
+ "预编译模式下 @column:value 中 value里面用 , 分割的每一项"
+ " column:alias 中 column 必须是1个单词!如果有alias,则alias也必须为1个单词!"
+ "关键字必须全大写,且以空格分隔的参数,空格必须只有 1 个!其它情况不允许空格!");
}
} else {
if (origin.startsWith("_") || origin.contains("--")) {
// || PATTERN_FUNCTION.matcher(origin).matches() == false) {
throw new IllegalArgumentException("字符 " + ck + " 不合法!"
+ "预编译模式下 @column:\"column0,column1:alias;function0(arg0,arg1,...);function1(...):alias...\""
+ " 中所有 arg 都必须是1个不以 _ 开头的单词 或者符合正则表达式 "
+ PATTERN_FUNCTION + " 且不包含连续减号 -- !" +
"DISTINCT 必须全大写,且后面必须有且只有 1 个空格!其它情况不允许空格!");
}
}
}
}
// 以空格分割参数View on GitHub (pinned to 5284052872)
Solutions
- Join items with ',' only — no space: "id,name,sex".
- No spaces around ':' in column:alias.
- Write keywords like DISTINCT fully uppercase with exactly one following space: "DISTINCT id".
- Ensure each token is a bare identifier; drop trailing commas.
Example fix
// before
{"User":{"@column":"id, name, distinct sex"}}
// after
{"User":{"@column":"id,name,DISTINCT sex"}} Defensive patterns
Strategy: validation
Validate before calling
const NAME=/^[A-Za-z][A-Za-z0-9_]*$/;
function okColList(v){return v.split(',').every(it=>{const i=it.lastIndexOf(':');const o=i<0?it:it.slice(0,i);const a=i<0?null:it.slice(i+1);return NAME.test(o)&&(a==null||a===''||NAME.test(a))});}
if(!okColList(colVal))throw new Error('each column:alias must be single words, comma without spaces'); Type guard
function isValidColumnList(v) { return v.split(',').every(it => { const i = it.lastIndexOf(':'); const o = i < 0 ? it : it.slice(0, i); const a = i < 0 ? null : it.slice(i + 1); return /^[A-Za-z][A-Za-z0-9_]*$/.test(o) && (a == null || a === '' || /^[A-Za-z][A-Za-z0-9_]*$/.test(a)); }); } Try / catch
catch IllegalArgumentException; normalize (strip spaces, fix keyword case) and retry once
Prevention
- Join columns with ',' not ', '
- Write keywords like DISTINCT fully uppercase with exactly one space
- No spaces around ':' in column:alias items
When it happens
Trigger: "@column":"id : name" (spaces around colon), "@column":"user.id:name" (dot), "@column":"distinct id,name" (lowercase keyword), or "@column":"id," (trailing comma producing an empty token).
Common situations: Building @column by joining a list with ', ' (comma+space) instead of ','; copying SQL fragments verbatim; case-sensitive DISTINCT/CAST keywords written lowercase.
Related errors
- POST请求: 每一个 key:value 中的key都必须是1个单词!
- 字符串 {alias} 不合法!预编译模式下 {key}:value 中 value里面用 ; 分割的每一项 funct
- 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/041a6ecf1b674ef1.
Report an issue: GitHub.