apache/cassandra · error · ConfigurationException

must be one of

Error message

%s must be one of %s

What it means

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).

Solutions

  1. Set ec2_metadata_type to exactly v1 or v2 in cassandra.yaml
  2. Check for stray whitespace/quotes/case in the property value
  3. Remove the property entirely to use the default (v2)
  4. If IMDSv1 must be used because IMDSv2 is disabled on the instance, set ec2_metadata_type: v1

Example fix

// before (cassandra.yaml)
ec2_metadata_type: IMDSv2
// after
ec2_metadata_type: v2
Defensive patterns

Strategy: validation

Validate before calling

String t = props.get("ec2_metadata_type", "v2");
if (!t.equals("v1") && !t.equals("v2")) throw new IllegalArgumentException("ec2_metadata_type must be v1 or v2, got: " + t);

Try / catch

try { Ec2MetadataServiceConnector.create(props); }
catch (ConfigurationException e) { logger.error("Invalid ec2_metadata_type: {}", e.getMessage()); }

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/locator/Ec2MetadataServiceConnector.java:77

        {
            this.provider = provider;
        }

        Ec2MetadataServiceConnector create(SnitchProperties properties)
        {
            return provider.apply(properties);
        }
    }

    static Ec2MetadataServiceConnector create(SnitchProperties props)
    {
        try
        {
            return EC2MetadataType.valueOf(props.get(EC2_METADATA_TYPE_PROPERTY, v2.name())).create(props);
        }
        catch (IllegalArgumentException ex)
        {
            throw new ConfigurationException(format("%s must be one of %s", EC2_METADATA_TYPE_PROPERTY,
                                                    stream(EC2MetadataType.values()).map(Enum::name).collect(joining(", "))));
        }
    }

    static class V1Connector extends Ec2MetadataServiceConnector
    {
        static V1Connector create(SnitchProperties props)
        {
            return new V1Connector(props);
        }

        V1Connector(SnitchProperties props)
        {
            super(props);
        }

        @Override
        public String toString()

View on GitHub (pinned to 88fd0f6a0e)