{"record":{"id":"b53fdc728ab5e56c","repo":"apache/cassandra","slug":"detected-environment-variable-override-for-c","errorCode":null,"errorMessage":"Detected environment variable {}={} override for Cassandra configuration '{}'.","messagePattern":"Detected environment variable (.+?)=(.+?) override for Cassandra configuration '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/java/org/apache/cassandra/config/YamlConfigurationLoader.java","lineNumber":240,"sourceCode":"    {\n        if (CONFIG_ALLOW_ENVIRONMENT_VARIABLES.getBoolean(CASSANDRA_ALLOW_CONFIG_ENVIRONMENT_VARIABLES.getBooleanOrDefault(false)))\n        {\n            Map<String, String> orderedEnvironmentMap = new TreeMap<>(System.getenv()); // checkstyle: suppress nearby 'blockSystemPropertyUsage'\n            Map<String, Object> overridingProperties = new HashMap<>();\n            for (Map.Entry<String, String> env : orderedEnvironmentMap.entrySet())\n            {\n                String originalKey = env.getKey();\n                if (env.getKey().startsWith(ENVIRONMENT_VARIABLE_PREFIX))\n                {\n                    String configKey = LocalizeString.toLowerCaseLocalized(originalKey.replace(ENVIRONMENT_VARIABLE_PREFIX, \"\")\n                                                                                      .replace(NESTED_CONFIG_SEPARATOR_ENVIRONMENT, NESTED_CONFIG_SEPARATOR));\n                    String configValue = env.getValue();\n                    if (OVERRIDABLE_CONFIG_NAMES.contains(configKey))\n                    {\n                        if (configValue != null && !overridingProperties.containsKey(configKey))\n                        {\n                            if (!DatabaseDescriptor.hasLoggedConfig()) // CASSANDRA-9909: Avoid flooding config during initialization\n                                logger.warn(\"Detected environment variable {}={} override for Cassandra configuration '{}'.\", originalKey, configValue, configKey);\n                            overridingProperties.put(configKey, getScalarOrJsonTree(configValue));\n                        }\n                    }\n                    else\n                    {\n                        logger.warn(\"Used environment property variable {} to override Cassandra configuration but there is no such environment property counter-part to override.\", originalKey);\n                    }\n                }\n            }\n            if (!overridingProperties.isEmpty())\n                updateFromMap(maybeFlattenNestedProperties(overridingProperties), false, obj);\n        }\n    }\n\n    private static Map<String, Object> maybeFlattenNestedProperties(Map<String, Object> overridingProperties)\n    {\n        Map<String, Object> copyOfProperties = new HashMap<>(overridingProperties);\n        for (Map.Entry<String, Object> entry : overridingProperties.entrySet())","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java#L222-L258","documentation":"Warning from YamlConfigurationLoader.maybeAddEnvironmentVariables when an environment variable following the CASSANDRA_ prefix convention maps to a recognized overridable configuration key. The value overrides cassandra.yaml (after scalar/JSON-tree conversion) and is logged once during initialization (CASSANDRA-9909 flood guard). This makes env-based config explicit at startup.","triggerScenarios":"Launching with an env var like CASSANDRA_CLUSTER_NAME=prod or CASSANDRA_NATIVE_TRANSPORT_PORT=9042 whose derived configKey is in OVERRIDABLE_CONFIG_NAMES; typical of containerized deployments (Docker/Kubernetes) injecting CASSANDRA_* variables.","commonSituations":"Docker images and Helm charts setting CASSANDRA_* env vars that silently override mounted cassandra.yaml; operators confused why yaml edits don't take effect; CI environments exporting CASSANDRA_* variables for tests.","solutions":["If yaml should win, unset the CASSANDRA_* env var in the deployment (remove from container spec / entrypoint).","If intentional, no action; but document the precedence: env var > system property context > cassandra.yaml value.","Inspect effective configuration at runtime to confirm which value is in force.","Standardize config source in container deployments — prefer one mechanism to avoid drift."],"exampleFix":"// before (k8s env)\nenv: [{name: CASSANDRA_CLUSTER_NAME, value: OverrideName}]\n// after\n# env removed; cluster_name comes from cassandra.yaml","handlingStrategy":"validation","validationCode":"# list env overrides in effect before start\nenv | grep '^CASSANDRA_' || echo 'no env overrides'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In containers, prefer a single config source (env or yaml), not both.","Remember precedence: CASSANDRA_* env vars override cassandra.yaml.","Audit Helm/Docker templates for which env keys are set."],"tags":["configuration","environment-variables","yaml","containers"],"backgroundTag":"invalid-config-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"}