{"record":{"id":"b950c31eecc9d172","repo":"apache/cassandra","slug":"property-s-was-set-to-s-seconds-which-is-not-in","errorCode":null,"errorMessage":"property %s was set to %s seconds which is not in allowed range of [%s..%s]","messagePattern":"property (.+?) was set to (.+?) seconds which is not in allowed range of \\[(.+?)\\.\\.(.+?)\\]","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java","lineNumber":130,"sourceCode":"        static int HTTP_REQUEST_RETRIES = 1;\n\n        private Pair<String, Long> token;\n        @VisibleForTesting\n        final Duration tokenTTL;\n\n        static V2Connector create(SnitchProperties props)\n        {\n            String tokenTTLString = props.get(AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY,\n                                              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);","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java#L112-L148","documentation":"When using the IMDSv2 connector, the token TTL property (ec2_metadata_token_ttl_seconds) must fall within the allowed range [MIN_TOKEN_TIME_IN_SECONDS..MAX_TOKEN_TIME_IN_SECONDS]. Values outside the range throw ConfigurationException at connector creation time.","triggerScenarios":"create() parses ec2_metadata_token_ttl_seconds via Integer.parseInt, and the resulting Duration in seconds is < MIN_TOKEN_TIME_IN_SECONDS or > MAX_TOKEN_TIME_IN_SECONDS (IMDS allows 1–21600 seconds).","commonSituations":"Operator sets a TTL of 0 or 60 thinking it's a refresh hint; copy-paste of a value like 86400 (a day) exceeding the 6-hour IMDSv2 max; confusion between milliseconds and seconds.","solutions":["Set ec2_metadata_token_ttl_seconds to a value between 1 and 21600 (e.g. 21600 for the maximum)","Remove the property to use the default TTL","If a longer effective session is needed, keep the max TTL — the connector refreshes tokens as required","Fix unit confusion: the property is in seconds, not ms or hours"],"exampleFix":"// before (cassandra.yaml)\nec2_metadata_token_ttl_seconds: 86400\n// after\nec2_metadata_token_ttl_seconds: 21600","handlingStrategy":"validation","validationCode":"long ttl = Long.parseLong(props.get(\"ec2_metadata_token_ttl_seconds\", \"21600\"));\nif (ttl < 1 || ttl > 21600) throw new IllegalArgumentException(\"TTL must be in [1..21600] seconds\");","typeGuard":null,"tryCatchPattern":"try { Ec2MetadataServiceConnector.create(props); }\ncatch (ConfigurationException e) { logger.error(\"Bad ec2_metadata_token_ttl_seconds: {}\", e.getMessage()); }","preventionTips":["Clamp TTL values to the documented 1–21600 range","Don't confuse seconds with milliseconds","Leave the property unset unless a specific TTL is required"],"tags":["configuration","ec2","ttl","value-range","metadata-service"],"backgroundTag":"value-out-of-range","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"}