{"record":{"id":"b16b79436efc5247","repo":"apache/cassandra","slug":"invalid-value-for-environment-variable-key-e","errorCode":null,"errorMessage":"Invalid value for environment variable '${key}': expected one of ${enumConstants} (case-insensitive) but was '${value}'","messagePattern":"Invalid value for environment variable '(.+?)': expected one of (.+?) \\(case-insensitive\\) but was '(.+?)'","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/CassandraRelevantEnv.java","lineNumber":88,"sourceCode":"    {\n        return Optional.ofNullable(System.getenv(key)).map(Boolean::parseBoolean).orElse(defaultValue);\n    }\n\n    public String getKey() {\n        return key;\n    }\n\n    public <T extends Enum<T>> T getEnum(boolean toUppercase, Class<T> enumClass, String defaultVal)\n    {\n        String value = System.getenv(key);\n        value = value == null ? defaultVal : value;\n        try\n        {\n            return Enum.valueOf(enumClass, toUppercase ? toUpperCaseLocalized(value) : value);\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new ConfigurationException(String.format(\"Invalid value for environment variable '%s': \" +\n                                                           \"expected one of %s (case-insensitive) but was '%s'\",\n                                                           key, Arrays.toString(enumClass.getEnumConstants()), value));\n        }\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/CassandraRelevantEnv.java#L70-L94","documentation":"Thrown by CassandraRelevantEnv.getEnum when an environment variable's value cannot be parsed as a constant of the requested enum class (case-insensitively when toUppercase is set). It wraps the IllegalArgumentException from Enum.valueOf into a Cassandra ConfigurationException with the expected values listed.","triggerScenarios":"Setting an env var consumed via CassandraRelevantEnv.getEnum to a value not present in the enum, e.g. JVM_TOOL_BEHAVIOR or disk-failure policy env overrides with a misspelled or unsupported value.","commonSituations":"Container/k8s env configuration with typos, values copied from documentation of a different Cassandra version where the enum gained/lost constants, lowercase values with toUppercase disabled.","solutions":["Set the env var to one of the enum constants exactly as listed in the exception message","Enable/honor case-insensitive parsing (toUppercase) or match the constant's case","Verify the value is supported in your Cassandra version","Catch ConfigurationException at startup and log a friendly message listing valid values"],"exampleFix":"// before\nexport JVM_EXTRA_OPTS=... CASSANDRA_DISK_FAILURE_POLICY=stop_all\n// after\nexport CASSANDRA_DISK_FAILURE_POLICY=stop","handlingStrategy":"validation","validationCode":"String v = System.getenv(\"CASSANDRA_DISK_FAILURE_POLICY\");\nSet<String> valid = Arrays.stream(DiskFailurePolicy.values())\n    .map(Enum::name).collect(Collectors.toSet());\nif (v != null && !valid.contains(v.toUpperCase(Locale.ROOT)))\n    throw new IllegalArgumentException(\"Bad env value: \" + v);","typeGuard":null,"tryCatchPattern":"try {\n    policy = CassandraRelevantEnv.SOME_ENUM.getEnum(DiskFailurePolicy.class);\n} catch (ConfigurationException e) {\n    logger.error(\"Fix the environment variable\", e);\n    policy = DiskFailurePolicy.DEFAULT;\n}","preventionTips":["Validate env vars in deployment pipelines before JVM start","Match enum constant names exactly or verify case-insensitivity","Check enum constants for your target Cassandra version"],"tags":["configuration","environment","enum"],"backgroundTag":"invalid-env-var-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}