{"record":{"id":"0e3c4ab5f921dcfe","repo":"apache/cassandra","slug":"is-defined-multiple-times-each-option-command-ca","errorCode":null,"errorMessage":" is defined multiple times. Each option/command can be specified at most once.","messagePattern":" is defined multiple times\\. Each option/command can be specified at most once\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java","lineNumber":269,"sourceCode":"            if (i == 0 || args[i].startsWith(\"-\"))\n            {\n                if (i > 0)\n                    putParam(key, params.toArray(new String[0]), r);\n                key = toLowerCaseLocalized(args[i]);\n                params.clear();\n            }\n            else\n                params.add(args[i]);\n        }\n        putParam(key, params.toArray(new String[0]), r);\n        return r;\n    }\n\n    private static void putParam(String key, String[] args, Map<String, String[]> clArgs)\n    {\n        String[] prev = clArgs.put(key, args);\n        if (prev != null)\n            throw new IllegalArgumentException(key + \" is defined multiple times. Each option/command can be specified at most once.\");\n    }\n\n    public static void printHelp()\n    {\n        SettingsMisc.printHelp();\n    }\n\n    public void printSettings(ResultLogger out)\n    {\n        out.println(\"******************** Stress Settings ********************\");\n        // done\n        out.println(\"Command:\");\n        command.printSettings(out);\n        out.println(\"Rate:\");\n        rate.printSettings(out);\n        out.println(\"Population:\");\n        generate.printSettings(out);\n        out.println(\"Insert:\");","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java#L251-L287","documentation":"The stress CLI parses arguments into a map keyed by option/command name; putParam throws IllegalArgumentException when the same key is seen a second time, since each option or command may be specified at most once on the command line.","triggerScenarios":"Repeating any option or command, e.g. 'cassandra-stress write -log interval=10s -log level=debug' or '-node a -node b' — the second occurrence triggers the error naming the duplicated key.","commonSituations":"Concatenating option strings from multiple config sources in scripts, shell loops appending the same flag per item instead of comma-joining values.","solutions":["Remove duplicate occurrences of the named option from the command line","Combine values into a single occurrence where the option accepts lists, e.g. -node ip1,ip2 or -log interval=10s level=debug","Fix the script that builds the arguments to deduplicate flags"],"exampleFix":"// before\n-node 127.0.0.1 -node 127.0.0.2\n// after\n-node 127.0.0.1,127.0.0.2","handlingStrategy":"validation","validationCode":"Map<String,Integer> seen = new HashMap<>();\nfor (String a : args) if (a.startsWith(\"-\")) {\n  int n = seen.merge(a, 1, Integer::sum);\n  if (n > 1) throw new IllegalArgumentException(a + \" repeated\");\n}","typeGuard":null,"tryCatchPattern":"try { StressSettings.get(parseMap(rawArgs)); } catch (IllegalArgumentException e) { if (e.getMessage().endsWith(\"defined multiple times\")) { dedupe(rawArgs); retry(); } else throw e; }","preventionTips":["Deduplicate flags when assembling command lines from multiple config sources","Use list syntax (-node ip1,ip2) instead of repeating an option","Log the final assembled command line before execution to catch accidental duplicates"],"tags":["cli","duplicate-argument","config"],"backgroundTag":"invalid-cli-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}