{"record":{"id":"63ff59dd8a415b09","repo":"Tencent/APIJSON","slug":"key-value-tbl","errorCode":null,"errorMessage":"${key}: value 中 ${tbl} 已经存在，不能重复！","messagePattern":"(.+?): value 中 (.+?) 已经存在，不能重复！","errorType":"validation","errorClass":"ConflictException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractParser.java","lineNumber":2317,"sourceCode":"\t\tKEY_METHOD_ENUM_MAP.put(KEY_HEAD, RequestMethod.HEAD);\n\t\tKEY_METHOD_ENUM_MAP.put(KEY_HEADS, RequestMethod.HEADS);\n\t\tKEY_METHOD_ENUM_MAP.put(KEY_POST, RequestMethod.POST);\n\t\tKEY_METHOD_ENUM_MAP.put(KEY_PUT, RequestMethod.PUT);\n\t\tKEY_METHOD_ENUM_MAP.put(KEY_DELETE, RequestMethod.DELETE);\n\t}\n\n\tprivate void parseMethodDirective(String key, RequestMethod keyMethod, @NotNull M request) throws Exception {\n\t\tboolean isPost = KEY_POST.equals(key);\n\t\tObject val = request.get(key);\n\t\tMap<String, Object> obj = val instanceof Map<?, ?> ? JSON.get(request, key) : null;\n\t\tif (obj == null) {\n\t\t\tif (val instanceof String) {\n\t\t\t\tString[] tbls = StringUtil.split((String) val);\n\t\t\t\tif (tbls != null && tbls.length > 0) {\n\t\t\t\t\tobj = new LinkedHashMap<String, Object>();\n\t\t\t\t\tfor (String tbl : tbls) {\n\t\t\t\t\t\tif (obj.containsKey(tbl)) {\n\t\t\t\t\t\t\tthrow new ConflictException(key + \": value 中 \" + tbl + \" 已经存在，不能重复！\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tobj.put(tbl, isPost && isTableArray(tbl)\n\t\t\t\t\t\t\t\t? tbl.substring(0, tbl.length() - 2) + \":[]\" : \"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new IllegalArgumentException(key + \": value 中 value 类型错误，只能是 String 或 Map<String, Object> {} ！\");\n\t\t\t}\n\t\t}\n\n\t\tSet<Entry<String, Object>> set = obj == null ? new HashSet<>() : obj.entrySet();\n\t\tfor (Entry<String, Object> objEntry : set) {\n\t\t\tString objKey = objEntry == null ? null : objEntry.getKey();\n\t\t\tif (objKey == null) {\n\t\t\t\tcontinue;\n\t\t\t}","sourceCodeStart":2299,"sourceCodeEnd":2335,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractParser.java#L2299-L2335","documentation":"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.","triggerScenarios":"{ '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).","commonSituations":"Concatenating table lists from multiple code paths without deduplicating; user-composed input where the same table is selected twice; trailing duplicates introduced by templating.","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"],"exampleFix":"// before\n{ 'INSERT': 'User, User, Comment' }\n// after\n{ 'INSERT': 'User, Comment' }","handlingStrategy":"validation","validationCode":"function dedupeMethodDirective(directive, value) {\n  if (typeof value !== 'string') return value;\n  const seen = new Set();\n  const out = [];\n  for (const t of value.split(/[\\s,]+/).filter(Boolean)) {\n    if (!seen.has(t)) { seen.add(t); out.push(t); }\n  }\n  if (out.length !== value.split(/[\\s,]+/).filter(Boolean).length) {\n    console.warn(`${directive}: duplicates removed -> ${out.join(', ')}`);\n  }\n  return out.join(', ');\n}\n// request[directive] = dedupeMethodDirective('INSERT', request['INSERT']);","typeGuard":null,"tryCatchPattern":"Catch ConflictException containing '不能重复'; deduplicate the directive string and retry once.","preventionTips":["Deduplicate table lists before concatenating them into 'INSERT'/'UPDATE'/'DELETE' strings","Build directive values from a Set rather than array concatenation"],"tags":["apijson","method-directive","duplicate","validation"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}