apache/cassandra · error · SyntaxException

Invalid value for property

Error message

Invalid value for property '%s'. It should be a string

What it means

PropertyDefinitions.getString() retrieves a WITH-clause property expected to be a plain string. If the property exists but its parsed value is not a String (e.g. a number, map, or set literal), a SyntaxException is thrown telling the caller the value must be a string.

Solutions

  1. Quote the value so the parser produces a string: option = 'value'.
  2. Inspect the statement's WITH clause and change the value's literal type to a string.
  3. If using a query builder, pass a String-typed value for string properties.

Example fix

-- before
CREATE ROLE r WITH option = 123; -- numeric where string expected
-- after
CREATE ROLE r WITH option = '123';
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = options.get(name); if (v != null && !(v instanceof String)) throw new IllegalArgumentException(name + " must be a string");

Type guard

boolean isStringOption(Object v) { return v == null || v instanceof String; }

Try / catch

try { session.execute(ddl); } catch (SyntaxException e) { if (e.getMessage().contains("should be a string")) { /* quote the value */ } else throw e; }

Prevention

When it happens

Trigger: A property retrieved via getString (e.g. string-valued table/role options) was supplied as a numeric, boolean, or collection literal in the WITH clause.

Common situations: Quoting mistakes: forgetting quotes around an option value; query builders passing typed values where strings are required; copy-paste from options expecting maps.

Related errors


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

Appendix: source

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

    }

    public void removeProperty(String name)
    {
        properties.remove(name);
    }

    public boolean hasProperty(String name)
    {
        return properties.containsKey(name);
    }

    public String getString(String name) throws SyntaxException
    {
        Object val = properties.get(name);
        if (val == null)
            return null;
        if (!(val instanceof String))
            throw new SyntaxException(format("Invalid value for property '%s'. It should be a string", name));
        return (String)val;
    }

    @Nullable
    public Set<QualifiedName> getQualifiedNames(String name) throws SyntaxException
    {
        Object val = properties.get(name);
        if (val == null)
            return null;
        if (val instanceof Map && ((Map<?, ?>)val).isEmpty()) // to solve the ambiguity between empty map and empty set
            return Collections.emptySet();
        if (!(val instanceof Set))
            throw new SyntaxException(String.format("Invalid value for property '%s'. It should be a set of identifiers.", name));
        return (Set<QualifiedName>) val;
    }

    @Nullable
    protected Map<String, String> getMap(String name) throws SyntaxException

View on GitHub (pinned to 88fd0f6a0e)