apache/cassandra · warning

Unable to parse value

Error message

Unable to parse value %s of key %s. Value has to be integer. The default of value %s will be used.

What it means

CustomGuardrailConfig.resolveInteger parses a guardrail config value expected to be a String containing an integer. If the value cannot be parsed (NumberFormatException) or the value type is unsupported (IllegalStateException), the method logs this warning and falls back to the configured default value instead of failing startup.

Solutions

  1. Fix the config value for the offending key to be a valid integer string (e.g. '12' not 'twelve' or '12.0').
  2. Check the warn log line for the key and resolved value to identify which key is wrong.
  3. If the value is intentionally a non-String type, quote it in YAML or adjust the custom guardrail's config parsing to accept that type.
  4. Remove the key so the guardrail uses its default value.

Example fix

// before (cassandra.yaml)
custom_guardrails:
  - name: password_policy
    password_min_length: ten
// after
liquid(custom_guardrails):
  - name: password_policy
    password_min_length: 10
Defensive patterns

Strategy: validation

Validate before calling

Object v = config.get(key);
if (!(v instanceof String) || !((String) v).matches("-?\\d+")) {
    throw new IllegalArgumentException("Key " + key + " must be an integer string, got: " + v);
}

Type guard

boolean isIntegerString(Object v) { return v instanceof String && ((String) v).matches("-?\\d+"); }

Prevention

When it happens

Trigger: Setting a guardrail config key (e.g. via cassandra.yaml guardrails configuration or a custom guardrail's config map) to a non-integer string like "abc" or "10.5", or to a non-String object (e.g. Integer or Boolean), when resolveInteger is called by CassandraPasswordConfiguration or UUIDRoleNameGenerator during guardrail initialization.

Common situations: Typo or wrong unit in a YAML guardrail value (e.g. 'password length: ten'); YAML auto-typing turning a quoted number into a non-String type; copying config between versions where the value format changed.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/db/guardrails/CustomGuardrailConfig.java:84

    public int resolveInteger(@Nullable String key, Integer defaultValue)
    {
        if (key == null)
            return defaultValue;

        Object resolvedValue = getOrDefault(key, defaultValue.toString());

        try
        {
            if (resolvedValue instanceof Integer)
                return (Integer) resolvedValue;
            if (resolvedValue instanceof String)
                return Integer.parseInt((String) resolvedValue);

            throw new IllegalStateException();
        }
        catch (IllegalStateException | NumberFormatException ex)
        {
            logger.warn(format("Unable to parse value %s of key %s. Value has to be integer. " +
                               "The default of value %s will be used.",
                               resolvedValue, key, defaultValue));
        }
        return defaultValue;
    }

    public boolean resolveBoolean(@Nullable String key, boolean defaultValue)
    {
        Object value = get(key);

        if (value == null)
            return defaultValue;
        if (value instanceof Boolean)
            return (boolean) value;
        if (value instanceof String)
            return Boolean.parseBoolean((String) value);

        return defaultValue;

View on GitHub (pinned to 88fd0f6a0e)