apache/cassandra · error · ConfigurationException
Unable to parse integer from property
Error message
Unable to parse integer from property %s, value to parse: %s
What it means
The ec2_metadata_token_ttl_seconds property must parse as a plain integer number of seconds. NumberFormatException from Integer.parseInt is wrapped in a ConfigurationException telling the operator the property value is not a valid integer.
Solutions
- Set ec2_metadata_token_ttl_seconds to a bare integer like 21600
- Strip units, commas, whitespace, and quotes from the value
- If the value comes from an env var, trim() it before injecting into config
- Remove the property to fall back to the default TTL
Example fix
// before (cassandra.yaml) ec2_metadata_token_ttl_seconds: 6h // after ec2_metadata_token_ttl_seconds: 21600
Defensive patterns
Strategy: validation
Validate before calling
String v = props.get("ec2_metadata_token_ttl_seconds", "");
if (!v.isEmpty() && !v.trim().matches("\\d+")) throw new IllegalArgumentException("ec2_metadata_token_ttl_seconds must be an integer: " + v); Try / catch
try { Ec2MetadataServiceConnector.create(props); }
catch (ConfigurationException e) { logger.error("Non-integer ec2_metadata_token_ttl_seconds: {}", e.getMessage()); } Prevention
- Always use plain decimal integers for numeric Cassandra properties
- Trim env-var-derived values
- Validate YAML numerics after editing cassandra.yaml
When it happens
Trigger: create() calls Integer.parseInt(tokenTTLString) on the value of ec2_metadata_token_ttl_seconds and it contains non-numeric text (e.g. '6h', '21,600', '21600s', or empty string).
Common situations: Values written with units ('3600s', '1h'); thousands separators ('21,600'); quoted YAML values carrying extra characters; property sourced from an environment variable with trailing whitespace/newline.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- property was set to seconds which is not in allowed range…
- does not end in unit
- Request on table . with %sttl of seconds exceeds maximum…
- is not a parsable float for
- is not a parsable int (base10) for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/440b6126130823a9.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java:139
Integer.toString(MAX_TOKEN_TIME_IN_SECONDS));
Duration tokenTTL;
try
{
tokenTTL = Duration.ofSeconds(Integer.parseInt(tokenTTLString));
if (tokenTTL.getSeconds() < MIN_TOKEN_TIME_IN_SECONDS || tokenTTL.getSeconds() > MAX_TOKEN_TIME_IN_SECONDS)
{
throw new ConfigurationException(format("property %s was set to %s seconds which is not in allowed range of [%s..%s]",
AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY,
tokenTTL.getSeconds(),
MIN_TOKEN_TIME_IN_SECONDS,
MAX_TOKEN_TIME_IN_SECONDS));
}
}
catch (NumberFormatException ex)
{
throw new ConfigurationException(format("Unable to parse integer from property %s, value to parse: %s",
AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY, tokenTTLString));
}
return new V2Connector(props, tokenTTL);
}
V2Connector(SnitchProperties properties, Duration tokenTTL)
{
super(properties);
this.tokenTTL = tokenTTL;
}
@Override
public String apiCall(String url, String query, String method, Map<String, String> extraHeaders, int expectedResponseCode) throws IOException
{
Map<String, String> headers = new HashMap<>(extraHeaders);
for (int retry = 0; retry <= HTTP_REQUEST_RETRIES; retry++)
{View on GitHub (pinned to 88fd0f6a0e)