Tencent/APIJSON · error · ConflictException
${key}: value 中 ${tbl} 已经存在,不能重复!
Error message
${key}: value 中 ${tbl} 已经存在,不能重复! What it means
When a METHOD directive ('INSERT', 'UPDATE', 'DELETE', 'POST'...) is given as a whitespace-separated String of table names, the parser builds a map from them; a name appearing twice produces this ConflictException because each table may be targeted only once per directive.
Source
Thrown at APIJSONORM/src/main/java/apijson/orm/AbstractParser.java:2317
KEY_METHOD_ENUM_MAP.put(KEY_HEAD, RequestMethod.HEAD);
KEY_METHOD_ENUM_MAP.put(KEY_HEADS, RequestMethod.HEADS);
KEY_METHOD_ENUM_MAP.put(KEY_POST, RequestMethod.POST);
KEY_METHOD_ENUM_MAP.put(KEY_PUT, RequestMethod.PUT);
KEY_METHOD_ENUM_MAP.put(KEY_DELETE, RequestMethod.DELETE);
}
private void parseMethodDirective(String key, RequestMethod keyMethod, @NotNull M request) throws Exception {
boolean isPost = KEY_POST.equals(key);
Object val = request.get(key);
Map<String, Object> obj = val instanceof Map<?, ?> ? JSON.get(request, key) : null;
if (obj == null) {
if (val instanceof String) {
String[] tbls = StringUtil.split((String) val);
if (tbls != null && tbls.length > 0) {
obj = new LinkedHashMap<String, Object>();
for (String tbl : tbls) {
if (obj.containsKey(tbl)) {
throw new ConflictException(key + ": value 中 " + tbl + " 已经存在,不能重复!");
}
obj.put(tbl, isPost && isTableArray(tbl)
? tbl.substring(0, tbl.length() - 2) + ":[]" : "");
}
}
}
else {
throw new IllegalArgumentException(key + ": value 中 value 类型错误,只能是 String 或 Map<String, Object> {} !");
}
}
Set<Entry<String, Object>> set = obj == null ? new HashSet<>() : obj.entrySet();
for (Entry<String, Object> objEntry : set) {
String objKey = objEntry == null ? null : objEntry.getKey();
if (objKey == null) {
continue;
}View on GitHub (pinned to 5284052872)
Solutions
- Deduplicate the table list before sending: 'User, Comment' instead of 'User, User, Comment'
- If the same table needs two different operations, list it under the appropriate distinct directive keys
Example fix
// before
{ 'INSERT': 'User, User, Comment' }
// after
{ 'INSERT': 'User, Comment' } Defensive patterns
Strategy: validation
Validate before calling
function dedupeMethodDirective(directive, value) {
if (typeof value !== 'string') return value;
const seen = new Set();
const out = [];
for (const t of value.split(/[\s,]+/).filter(Boolean)) {
if (!seen.has(t)) { seen.add(t); out.push(t); }
}
if (out.length !== value.split(/[\s,]+/).filter(Boolean).length) {
console.warn(`${directive}: duplicates removed -> ${out.join(', ')}`);
}
return out.join(', ');
}
// request[directive] = dedupeMethodDirective('INSERT', request['INSERT']); Try / catch
Catch ConflictException containing '不能重复'; deduplicate the directive string and retry once.
Prevention
- Deduplicate table lists before concatenating them into 'INSERT'/'UPDATE'/'DELETE' strings
- Build directive values from a Set rather than array concatenation
When it happens
Trigger: { 'INSERT': 'User, User' } or { 'POST': 'Moment Moment' } — duplicate tokens in the directive string (duplicates inside a Map value like { 'User': {}, 'User': {} } are impossible in JSON parsing, so the String form is the trigger).
Common situations: Concatenating table lists from multiple code paths without deduplicating; user-composed input where the same table is selected twice; trailing duplicates introduced by templating.
Related errors
- Cannot convert value of type " + value.getClass().getName()
- 字符 " + function + " 不合法!
- 字符 " + method + " 不合法!函数的名称 function 不能为空且必须符合方法命名规范!总体必须为 f
- 字符 {} 不合法!远程函数不允许指定类名!且必须为 function(key0,key1,...) 这种单函数格式!\
- {}: { @key(): value } 对应存储过程 value 中字符 {} 不合法!`schema` 当有 `
AI-assisted analysis of Tencent/APIJSON@5284052872 (2026-08-14).
Data as JSON: /api/errors/63ff59dd8a415b09.
Report an issue: GitHub.