{"record":{"id":"780a36200984676c","repo":"apache/cassandra","slug":"multiple-definition-for-property-s","errorCode":null,"errorMessage":"Multiple definition for property '%s'","messagePattern":"Multiple definition for property '(.+?)'","errorType":"exception","errorClass":"SyntaxException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/auth/RoleOptions.java","lineNumber":44,"sourceCode":"import org.apache.cassandra.config.DatabaseDescriptor;\nimport org.apache.cassandra.exceptions.InvalidRequestException;\nimport org.apache.cassandra.exceptions.SyntaxException;\nimport org.apache.cassandra.utils.FBUtilities;\n\npublic class RoleOptions\n{\n    private final Map<IRoleManager.Option, Object> options = new HashMap<>();\n\n    /**\n     * Set a value for a specific option.\n     * Throws SyntaxException if the same option is set multiple times\n     * @param option\n     * @param value\n     */\n    public void setOption(IRoleManager.Option option, Object value)\n    {\n        if (options.containsKey(option))\n            throw new SyntaxException(String.format(\"Multiple definition for property '%s'\", option.name()));\n        options.put(option, value);\n    }\n\n    /**\n     * Return true if there are no options with values set, false otherwise\n     * @return whether any options have values set or not\n     */\n    public boolean isEmpty()\n    {\n        return options.isEmpty();\n    }\n\n    /**\n     * Return a map of all the options which have been set\n     * @return all options with values\n     */\n    public Map<IRoleManager.Option, Object> getOptions()\n    {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/RoleOptions.java#L26-L62","documentation":"RoleOptions is a per-statement map of IRoleManager.Option -> value used by CREATE ROLE/ALTER ROLE. setOption() refuses to set an option that is already present in the map, throwing SyntaxException so a single CQL statement can't define the same role property twice.","triggerScenarios":"CREATE ROLE x WITH PASSWORD 'a' AND PASSWORD 'b'; or ALTER ROLE ... WITH LOGIN = true AND LOGIN = false — the same option key appears more than once in one statement (often via combined option lists built programmatically).","commonSituations":"Tooling concatenating option lists (e.g. superuser + login + password) that accidentally includes an option twice; hand-written CQL repeating PASSWORD or LOGIN; DSL/query builders accumulating options across calls.","solutions":["Deduplicate the options in the CQL statement — each WITH option may appear only once","In query-builder code, use a map keyed by option so later sets overwrite instead of appending","For changing an existing role's option, issue a second ALTER ROLE statement rather than repeating it in one"],"exampleFix":"// before\nCREATE ROLE app WITH PASSWORD 'p' AND PASSWORD 'p2' AND LOGIN = true;\n// after\nCREATE ROLE app WITH PASSWORD 'p' AND LOGIN = true;","handlingStrategy":"validation","validationCode":"Set<Option> seen = new HashSet<>(); for (Option o : opts) if (!seen.add(o)) fail(\"duplicate option: \" + o);","typeGuard":"boolean optionsAreUnique(List<Option> opts) { return opts.stream().distinct().count() == opts.size(); }","tryCatchPattern":"try { session.execute(createRoleStmt); } catch (SyntaxException e) { if (e.getMessage().contains(\"Multiple definition\")) dedupeAndRetry(); }","preventionTips":["Build role options in a Map<Option,Object> instead of a list","Unit-test generated CREATE/ALTER ROLE statements for duplicate options","Review hand-written CQL for repeated WITH clauses before running"],"tags":["cql","syntax","roles"],"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-14T16:17:12.679Z"}