xai-org/x-algorithm · error · ParseFailure
Duplicated argument name %s
Error message
Duplicated argument name %s
What it means
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.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/Parser.java:188
boolean hasOpt = false;
for (int i = 0; i < params.getChildCount(); i++) {
Tree arg = params.getChild(i);
if (arg.getType() == BotMakerLexer.ARG) {
String name = arg.getChild(1).getText();
if (arg.getChildCount() == 2 && hasOpt) {
throw new ParseFailure(
String.format(
"Non-optional parameter %s must be declared before optional parameters.",
name));
} else if (arg.getChildCount() == 2) {
ret.add(Tuple.of(arg.getChild(0), name, Optional.absent()));
} else {
hasOpt = true;
ret.add(Tuple.of(arg.getChild(0), name, Optional.of(arg.getChild(2))));
}
if (argNames.contains(name)) {
throw new ParseFailure("Duplicated argument name " + name);
}
argNames.add(name);
}
}
return ret.build();
}
public static Tree parseType(String expr) throws ParseFailure {
CharStream input = new ANTLRStringStream(expr);
BotMakerLexer lexer = new BotMakerLexer(input);
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
BotMakerParser parser = new BotMakerParser(tokenStream);
Tree root;
try {
root = (Tree) parser.type().getTree();
} catch (Exception e) {
if (e.getCause() instanceof RecognitionException) {View on GitHub (pinned to 24c60942c5)
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
Example fix
// before #params(userId, threshold=0.5, threshold=0.9) // after #params(userId, threshold=0.5, thresholdHigh=0.9)
Defensive patterns
Strategy: validation
Validate before calling
// Check for duplicate names before calling the parser
boolean noDuplicates(List<String> names) {
return names.stream().distinct().count() == names.size();
} Try / catch
try { Parser.parseParams(sig); } catch (ParseFailure pf) { /* message contains the duplicated name */ } Prevention
- Use an IDE/struct editor that prevents duplicate keys
- Check merge diffs for duplicated parameter lines
- Lint signatures in CI
When it happens
Trigger: A signature like #params(a, a=1) or #param(x, x) — the same argument name appearing twice in one parameter list.
Common situations: Copy/paste of a parameter line when extending a signature, or merge conflicts in config files producing duplicated lines.
Related errors
- Non-optional parameter %s must be declared before optional p
- Failed to parse DF signature '%s'%s
- unknown parse failure
- Failed to parse Type signature '%s'%s
- batch size must be a positive integer
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/039e8813e123a2e3.
Report an issue: GitHub.