{"record":{"id":"039e8813e123a2e3","repo":"xai-org/x-algorithm","slug":"duplicated-argument-name-s","errorCode":null,"errorMessage":"Duplicated argument name %s","messagePattern":"Duplicated argument name (.+?)","errorType":"validation","errorClass":"ParseFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Parser.java","lineNumber":188,"sourceCode":"    boolean hasOpt = false;\n    for (int i = 0; i < params.getChildCount(); i++) {\n      Tree arg = params.getChild(i);\n      if (arg.getType() == BotMakerLexer.ARG) {\n        String name = arg.getChild(1).getText();\n        if (arg.getChildCount() == 2 && hasOpt) {\n          throw new ParseFailure(\n              String.format(\n                  \"Non-optional parameter %s must be declared before optional parameters.\",\n                  name));\n        } else if (arg.getChildCount() == 2) {\n          ret.add(Tuple.of(arg.getChild(0), name, Optional.absent()));\n        } else {\n          hasOpt = true;\n          ret.add(Tuple.of(arg.getChild(0), name, Optional.of(arg.getChild(2))));\n        }\n\n        if (argNames.contains(name)) {\n          throw new ParseFailure(\"Duplicated argument name \" + name);\n        }\n        argNames.add(name);\n      }\n    }\n    return ret.build();\n  }\n\n  public static Tree parseType(String expr) throws ParseFailure {\n\n    CharStream input = new ANTLRStringStream(expr);\n    BotMakerLexer lexer = new BotMakerLexer(input);\n    CommonTokenStream tokenStream = new CommonTokenStream(lexer);\n    BotMakerParser parser = new BotMakerParser(tokenStream);\n    Tree root;\n    try {\n      root = (Tree) parser.type().getTree();\n    } catch (Exception e) {\n      if (e.getCause() instanceof RecognitionException) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Parser.java#L170-L206","documentation":"Enforced by Parser.buildParams: every parameter name in a params/DF signature must be unique. While iterating ARG nodes it accumulates names in argNames and throws ParseFailure if a name repeats, since duplicate named parameters would make argument binding ambiguous.","triggerScenarios":"A signature like #params(a, a=1) or #param(x, x) — the same argument name appearing twice in one parameter list.","commonSituations":"Copy/paste of a parameter line when extending a signature, or merge conflicts in config files producing duplicated lines.","solutions":["Rename or remove the duplicated argument identified in the message","Diff the signature against its previous version to find the accidental copy/paste or merge artifact","Add a config lint that rejects duplicate parameter names before submission"],"exampleFix":"// before\n#params(userId, threshold=0.5, threshold=0.9)\n\n// after\n#params(userId, threshold=0.5, thresholdHigh=0.9)","handlingStrategy":"validation","validationCode":"// Check for duplicate names before calling the parser\nboolean noDuplicates(List<String> names) {\n  return names.stream().distinct().count() == names.size();\n}","typeGuard":null,"tryCatchPattern":"try { Parser.parseParams(sig); } catch (ParseFailure pf) { /* message contains the duplicated name */ }","preventionTips":["Use an IDE/struct editor that prevents duplicate keys","Check merge diffs for duplicated parameter lines","Lint signatures in CI"],"tags":["parsing","duplicate-parameter","validation","botmaker"],"backgroundTag":"duplicate-parameter-name","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}