apache/cassandra · error · SyntaxException

Multiple definitions for property '%s'

Error message

Multiple definitions for property '%s'

What it means

PropertyDefinitions.addProperty() stores CREATE/ALTER statement properties (e.g. WITH options) in a map using putIfAbsent. If the same property is specified more than once in the statement, the second value is rejected with a SyntaxException formatted from MULTIPLE_DEFINITIONS_ERROR.

Source

Thrown at src/java/org/apache/cassandra/cql3/statements/PropertyDefinitions.java:50

import org.apache.cassandra.exceptions.SyntaxException;

import static java.lang.String.format;
import static org.apache.cassandra.utils.LocalizeString.toLowerCaseLocalized;

public class PropertyDefinitions
{
    public static final String MULTIPLE_DEFINITIONS_ERROR = "Multiple definitions for property '%s'";

    private static final Pattern POSITIVE_PATTERN = Pattern.compile("(1|true|yes)");
    private static final Pattern NEGATIVE_PATTERN = Pattern.compile("(0|false|no)");
    private static final Logger logger = LoggerFactory.getLogger(PropertyDefinitions.class);

    protected final Map<String, Object> properties = new HashMap<>();

    public void addProperty(String name, Object value) throws SyntaxException
    {
        if (properties.putIfAbsent(name, value) != null)
            throw new SyntaxException(format(MULTIPLE_DEFINITIONS_ERROR, name));
    }

    public void validate(Set<String> keywords, Set<String> obsolete) throws SyntaxException
    {
        for (String name : properties.keySet())
        {
            if (keywords.contains(name))
                continue;

            if (obsolete.contains(name))
                logger.warn("Ignoring obsolete property {}", name);
            else
                throw new SyntaxException(format("Unknown property '%s'", name));
        }
    }

    public Set<String> updatedProperties()
    {

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Remove the duplicate property from the WITH clause so each option appears once.
  2. If using a query builder, deduplicate options before rendering the statement.
  3. Choose one of the conflicting values intentionally and keep only it.

Example fix

-- before
CREATE KEYSPACE ks WITH replication = {...} AND replication = {...};
-- after
CREATE KEYSPACE ks WITH replication = {'class':'SimpleStrategy','replication_factor':3};
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (String opt : withClauseOptions) { if (!seen.add(opt)) throw new IllegalStateException("duplicate property " + opt); }

Prevention

When it happens

Trigger: CREATE KEYSPACE/TABLE/ROLE ... WITH option1 = x AND option1 = y; — duplicate property in the WITH clause.

Common situations: Programmatic query builders appending the same option twice; copy-paste in schema scripts; merging generated options fragments.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e63b0fddb2b2d6db. Report an issue: GitHub.