{"record":{"id":"7c153c8ac0a84c51","repo":"apache/cassandra","slug":"s-must-be-one-of-s","errorCode":null,"errorMessage":"%s must be one of %s","messagePattern":"(.+?) must be one of (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java","lineNumber":77,"sourceCode":"        {\n            this.provider = provider;\n        }\n\n        Ec2MetadataServiceConnector create(SnitchProperties properties)\n        {\n            return provider.apply(properties);\n        }\n    }\n\n    static Ec2MetadataServiceConnector create(SnitchProperties props)\n    {\n        try\n        {\n            return EC2MetadataType.valueOf(props.get(EC2_METADATA_TYPE_PROPERTY, v2.name())).create(props);\n        }\n        catch (IllegalArgumentException ex)\n        {\n            throw new ConfigurationException(format(\"%s must be one of %s\", EC2_METADATA_TYPE_PROPERTY,\n                                                    stream(EC2MetadataType.values()).map(Enum::name).collect(joining(\", \"))));\n        }\n    }\n\n    static class V1Connector extends Ec2MetadataServiceConnector\n    {\n        static V1Connector create(SnitchProperties props)\n        {\n            return new V1Connector(props);\n        }\n\n        V1Connector(SnitchProperties props)\n        {\n            super(props);\n        }\n\n        @Override\n        public String toString()","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java#L59-L95","documentation":"Ec2MetadataServiceConnector.create reads the ec2_metadata_type property and maps it to an EC2MetadataType enum via valueOf. An unrecognized value raises IllegalArgumentException, which is rethrown as a ConfigurationException listing the valid values (v1, v2).","triggerScenarios":"cassandra.yaml (or system properties) sets ec2_metadata_type to something other than the enum constant names — e.g. a typo like 'V1', 'V2 ', 'token', or 'IMDSv2'.","commonSituations":"Copy-pasted config from a blog with wrong casing; operator intent to force IMDSv2 by writing ec2_metadata_type: v2-full or similar invented values; environment with whitespace or quotes around the value.","solutions":["Set ec2_metadata_type to exactly v1 or v2 in cassandra.yaml","Check for stray whitespace/quotes/case in the property value","Remove the property entirely to use the default (v2)","If IMDSv1 must be used because IMDSv2 is disabled on the instance, set ec2_metadata_type: v1"],"exampleFix":"// before (cassandra.yaml)\nec2_metadata_type: IMDSv2\n// after\nec2_metadata_type: v2","handlingStrategy":"validation","validationCode":"String t = props.get(\"ec2_metadata_type\", \"v2\");\nif (!t.equals(\"v1\") && !t.equals(\"v2\")) throw new IllegalArgumentException(\"ec2_metadata_type must be v1 or v2, got: \" + t);","typeGuard":null,"tryCatchPattern":"try { Ec2MetadataServiceConnector.create(props); }\ncatch (ConfigurationException e) { logger.error(\"Invalid ec2_metadata_type: {}\", e.getMessage()); }","preventionTips":["Only use lowercase v1/v2 for ec2_metadata_type","Validate cassandra.yaml snitch-related properties after edits","Remember enum parsing is case-sensitive"],"tags":["configuration","ec2","enum","metadata-service"],"backgroundTag":"invalid-enum-value","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"}