apache/cassandra · error · SyntaxException

Invalid integer value

Error message

Invalid integer value %s for '%s'

What it means

PropertyDefinitions.parseInt() (via getInt) parses an integer-typed CQL property value with Integer.parseInt and wraps any NumberFormatException into a SyntaxException 'Invalid integer value %s for %s'. It means the property named in the message was given a value that is not a syntactically valid 32-bit integer.

Solutions

  1. Give a plain integer literal (e.g. gc_grace_seconds = 864000)
  2. Remove units, underscores, commas, or decimals from the value
  3. If a duration is intended, convert it to whole seconds/minutes as required by the option
  4. Check the option's docs for its valid numeric range and type

Example fix

// before
ALTER TABLE t WITH gc_grace_seconds = 5s;
// after
ALTER TABLE t WITH gc_grace_seconds = 5;
Defensive patterns

Strategy: validation

Validate before calling

if (!Number.isInteger(Number(value)) || String(value).trim() !== String(Number(value))) throw new Error(`Invalid integer for ${key}: ${value}`);

Type guard

function isPlainInt(v) { return /^-?\d+$/.test(String(v).trim()); }

Try / catch

try { runCql(stmt); } catch (e) { if (/Invalid integer value .* for/.test(e.message)) coerceIntProps(stmt); else throw e; }

Prevention

When it happens

Trigger: Supplying e.g. WITH comment-typed numeric properties such as gc_grace_seconds = 'forever', min/max-index-keys = 1024.5, or values with thousands separators (1_000, 1,000) in CREATE/ALTER TABLE or keyspace statements.

Common situations: Durations spelled as '5s' instead of seconds as an integer; decimal points in integer options; locale separators; copy from config files where the value is quoted or has units.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

    public int getInt(String key, int defaultValue) throws SyntaxException
    {
        String value = getString(key);
        return value != null ? parseInt(key, value) : defaultValue;
    }

    public static int parseInt(String key, String value) throws SyntaxException
    {
        if (null == value)
            throw new IllegalArgumentException("value argument can't be null");

        try
        {
            return Integer.parseInt(value);
        }
        catch (NumberFormatException e)
        {
            throw new SyntaxException(format("Invalid integer value %s for '%s'", value, key));
        }
    }

    public double getDouble(String key, double defaultValue) throws SyntaxException
    {
        String value = getString(key);
        return value != null ? parseDouble(key, value) : defaultValue;
    }

    public static double parseDouble(String key, String value) throws SyntaxException
    {
        if (null == value)
            throw new IllegalArgumentException("value argument can't be null");

        try
        {
            return Double.parseDouble(value);
        }

View on GitHub (pinned to 88fd0f6a0e)