{"record":{"id":"c601a30210c31db8","repo":"apache/cassandra","slug":"suboption-has-been-specified-more-than-once","errorCode":null,"errorMessage":"Suboption  has been specified more than once","messagePattern":"Suboption  has been specified more than once","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java","lineNumber":111,"sourceCode":"        return required;\n    }\n\n    public boolean present()\n    {\n        return value != null || defaultValue != null;\n    }\n\n    public String value()\n    {\n        return value != null ? value : defaultValue;\n    }\n\n    public boolean accept(String param)\n    {\n        if (matchPrefix.matcher(param).lookingAt())\n        {\n            if (value != null)\n                throw new IllegalArgumentException(\"Suboption \" + displayPrefix + \" has been specified more than once\");\n            String v = param.substring(displayPrefix.length());\n            value = valueAdapter.apply(v);\n            assert value != null;\n            return true;\n        }\n        return false;\n    }\n\n    @Override\n    public boolean happy()\n    {\n        return !required || value != null;\n    }\n\n    public String shortDisplay()\n    {\n        StringBuilder sb = new StringBuilder();\n        if (!required)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/OptionSimple.java#L93-L129","documentation":"OptionSimple represents a single-valued CLI option; it stores the parsed value in a field and throws if accept() is called again while a value is already set. This guards against specifying the same suboption twice on the command line, which would make the effective value ambiguous.","triggerScenarios":"Passing the same option flag twice in one cassandra-stress invocation, e.g. '-col n=5 n=10' or specifying an option both in a settings string and again on the command line, so accept(param) runs a second time with value != null.","commonSituations":"Scripting the stress command and accidentally appending a duplicate flag (a default plus an override); a wrapper concatenating two option lists that both set the same key; copy-pasting a flag inside the same -col/-rate group.","solutions":["Remove the duplicate flag so each suboption appears at most once per invocation.","If you intended to override, delete the earlier occurrence rather than adding a second one.","Audit wrapper scripts for flags appended by both a defaults block and a user block.","If you control the option-group code, check/deduplicate the argument list before feeding it to accept()."],"exampleFix":"// before\ncassandra-stress write n=1000000 -col n=5 n=10\n// after\ncassandra-stress write n=1000000 -col n=10","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (String arg : args) { String key = arg.contains(\"=\") ? arg.substring(0, arg.indexOf('=')) : arg; if (!seen.add(key)) throw new IllegalArgumentException(\"duplicate option: \" + key); }","typeGuard":null,"tryCatchPattern":"try { /* parse args */ } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"specified more than once\")) { /* log which flag is duplicated */ } throw e; }","preventionTips":["Keep a single source of truth for option values in wrapper scripts.","Grep generated command lines for repeated '-key=' prefixes before executing.","Override by replacing, not appending."],"tags":["cli","duplicate-argument","configuration"],"backgroundTag":"conflicting-config-options","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"}