{"record":{"id":"440b6126130823a9","repo":"apache/cassandra","slug":"unable-to-parse-integer-from-property-s-value-to","errorCode":null,"errorMessage":"Unable to parse integer from property %s, value to parse: %s","messagePattern":"Unable to parse integer from property (.+?), value to parse: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java","lineNumber":139,"sourceCode":"                                              Integer.toString(MAX_TOKEN_TIME_IN_SECONDS));\n\n            Duration tokenTTL;\n            try\n            {\n                tokenTTL = Duration.ofSeconds(Integer.parseInt(tokenTTLString));\n\n                if (tokenTTL.getSeconds() < MIN_TOKEN_TIME_IN_SECONDS || tokenTTL.getSeconds() > MAX_TOKEN_TIME_IN_SECONDS)\n                {\n                    throw new ConfigurationException(format(\"property %s was set to %s seconds which is not in allowed range of [%s..%s]\",\n                                                            AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY,\n                                                            tokenTTL.getSeconds(),\n                                                            MIN_TOKEN_TIME_IN_SECONDS,\n                                                            MAX_TOKEN_TIME_IN_SECONDS));\n                }\n            }\n            catch (NumberFormatException ex)\n            {\n                throw new ConfigurationException(format(\"Unable to parse integer from property %s, value to parse: %s\",\n                                                        AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY, tokenTTLString));\n            }\n\n            return new V2Connector(props, tokenTTL);\n        }\n\n        V2Connector(SnitchProperties properties, Duration tokenTTL)\n        {\n            super(properties);\n            this.tokenTTL = tokenTTL;\n        }\n\n        @Override\n        public String apiCall(String url, String query, String method, Map<String, String> extraHeaders, int expectedResponseCode) throws IOException\n        {\n            Map<String, String> headers = new HashMap<>(extraHeaders);\n            for (int retry = 0; retry <= HTTP_REQUEST_RETRIES; retry++)\n            {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java#L121-L157","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before (cassandra.yaml)\nec2_metadata_token_ttl_seconds: 6h\n// after\nec2_metadata_token_ttl_seconds: 21600","handlingStrategy":"validation","validationCode":"String v = props.get(\"ec2_metadata_token_ttl_seconds\", \"\");\nif (!v.isEmpty() && !v.trim().matches(\"\\\\d+\")) throw new IllegalArgumentException(\"ec2_metadata_token_ttl_seconds must be an integer: \" + v);","typeGuard":null,"tryCatchPattern":"try { Ec2MetadataServiceConnector.create(props); }\ncatch (ConfigurationException e) { logger.error(\"Non-integer ec2_metadata_token_ttl_seconds: {}\", e.getMessage()); }","preventionTips":["Always use plain decimal integers for numeric Cassandra properties","Trim env-var-derived values","Validate YAML numerics after editing cassandra.yaml"],"tags":["configuration","ec2","number-format","ttl"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}