Tencent/APIJSON · error · IllegalArgumentException
对象名重复,请添加别名区分 ! 重复对象名为: ${key}
Error message
对象名重复,请添加别名区分 ! 重复对象名为: ${key} What it means
During batchVerify, a key in the request already exists in correctRequest either as-is or with the array suffix — i.e. the same table object name appears twice (including xxx vs xxx[]). APIJSON cannot map two identical object names to one result slot, so it demands an alias.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:2415
RequestMethod keyMethod = KEY_POST.equals(key) ? RequestMethod.POST : KEY_METHOD_ENUM_MAP.get(key);
if (keyMethod == null) {
continue;
}
removeTmpKeys.add(key);
try {
parseMethodDirective(key, keyMethod, request);
}
catch (Exception e) {
Log.e(TAG, "parse method directive failed", e);
throw e;
}
}
for (String key : reqSet) {
// key 重复直接抛错(xxx:alias, xxx:alias[])
if (correctRequest.containsKey(key) || correctRequest.containsKey(key + KEY_ARRAY)) {
throw new IllegalArgumentException("对象名重复,请添加别名区分 ! 重复对象名为: " + key);
}
if (KEY_POST.equals(key) || KEY_METHOD_ENUM_MAP.containsKey(key)) {
continue;
}
try {
// 1、非crud,对于没有显式声明操作方法的,直接用 URL(/get, /post 等) 对应的默认操作方法
// 2、crud, 没有声明就用 GET
// 3、兼容 sql@ Map<String, Object>,设置 GET方法
// 将method 设置到每个object, op执行会解析
Object obj = request.get(key);
if (obj instanceof Map<?, ?>) {
Map<String, Object> attrMap = keyObjectAttributesMap.get(key);
if (attrMap == null) {
// 数组会解析为对象进行校验,做一下兼容View on GitHub (pinned to 5284052872)
Solutions
- Alias the second occurrence: "User": {...} and "User:adminList[]": {...}
- Deduplicate keys when assembling the request object client-side
- Use distinct aliases for every repeat of the same table in one request
Example fix
// before
{"User": {"id": 1}, "User": {"sex": 1}}
// after
{"User": {"id": 1}, "User:femaleList[]": {"sex": 1}} Defensive patterns
Strategy: validation
Validate before calling
const seen = new Set();
for (const k of Object.keys(req)) {
const base = k.replace(/:.*$/, '');
if (seen.has(base)) throw new Error(`duplicate table object ${base}; use alias Table:xxx`);
seen.add(base);
} Type guard
const isUniqueTableKey = (keys, k) => !keys.some(x => x.replace(/:.*$/, '') === k.replace(/:.*$/, '') && x !== k);
Try / catch
try { await client.crud(req); } catch (e) { if (e.message.includes('对象名重复')) autoAliasAndRetry(req, e); else throw e; } Prevention
- Always alias same-table repeats up front (User:a, User:b)
- Avoid building request JSON via string concatenation where dup keys survive
When it happens
Trigger: A JSON body containing two "User" keys, or both "User" and "User[]"; duplicate keys survive when JSON is built from a map that silently keeps the last entry client-side but a raw string body keeps both.
Common situations: Client merges two request fragments that both query the same table; wanting the same table twice with different conditions (e.g. one row and a list) without knowing about the alias syntax Table:alias.
Related errors
- join:value 中 value 的 alias 值 ${alias} 不合法!必须为 &/Table0,</Tab
- ${e.getKey()}:'/targetTable:targetAlias/targetKey' 中 targetA
- 字符串 {alias} 不合法!预编译模式下 {key}:value 中 value里面用 ; 分割的每一项 funct
- 字符 {ck} 不合法!预编译模式下 @column:value 中 value里面用 , 分割的每一项 column:
- Value for key '" + key + "' is not a Map: " + value.getClass
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/4e99014257034a86.
Report an issue: GitHub.