{"record":{"id":"dddfd68e17f9dbb1","repo":"quarkusio/quarkus","slug":"s-env-var-can-t-simultaneously-have-a-s-valu","errorCode":null,"errorMessage":"'%s' env var can't simultaneously have a '%s' value & take is value from the '%s' field","messagePattern":"'(.+?)' env var can't simultaneously have a '(.+?)' value & take is value from the '(.+?)' field","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java","lineNumber":94,"sourceCode":"    public static KubernetesEnvBuildItem createFromResourceKey(String varName, String key, String secret,\n            String configmap, String target) {\n        return create(varName, key, secret, configmap, null, target, null);\n    }\n\n    public static KubernetesEnvBuildItem create(String name, String value, String secret, String configmap, String field,\n            String target, String prefix) throws IllegalArgumentException {\n        final boolean secretPresent = secret != null;\n        final boolean configmapPresent = configmap != null;\n        final boolean valuePresent = value != null;\n        final boolean fieldPresent = field != null;\n        if (valuePresent) {\n            if (secretPresent && configmapPresent) {\n                throw new IllegalArgumentException(String.format(\n                        \"'%s' env var can't simultaneously take its value from '%s' configmap & '%s' secret\",\n                        name, configmap, secret));\n            }\n            if (fieldPresent) {\n                throw new IllegalArgumentException(String.format(\n                        \"'%s' env var can't simultaneously have a '%s' value & take is value from the '%s' field\",\n                        name, value, field));\n            }\n        }\n        if (secretPresent && configmapPresent) {\n            log.warn(String.format(\"The '%s' name was used to try to import both from '%s' secret & '%s' configmap. \" +\n                    \"Only values from '%s' secret will be imported.\\nIf you want to import from both, use a \" +\n                    \"different property name for either.\",\n                    name, secret,\n                    configmap,\n                    secret));\n        }\n        final EnvType type;\n        if (secretPresent) {\n            if (valuePresent) {\n                type = EnvType.keyFromSecret;\n            } else {\n                name = secret;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesEnvBuildItem.java#L76-L112","documentation":"KubernetesEnvBuildItem.create() validates that an env var cannot have both a literal value and take its value from a container field (e.g. metadata.name, spec.nodeName via fieldRef). The generated env entry supports either 'value' or 'valueFrom.fieldRef', not both, so when both value and field are non-null this IllegalArgumentException is thrown.","triggerScenarios":"Calling KubernetesEnvBuildItem.create(name, secret, configmap, value, field, ...) with both value and field non-null, e.g. a config that sets both a literal value and a field reference for the same env var.","commonSituations":"Copy-pasted env var config where a user adds field=metadata.name but forgets to remove the literal value; programmatic build item creation with leftover parameters; template-generated config with both keys populated.","solutions":["Remove the literal value and keep only the field reference, or vice versa","If you need the pod field, set the env var entry with only field=... (no value)","If you need a literal, drop the field parameter","Validate your quarkus.kubernetes.env-vars entries to ensure each has exactly one of value or field"],"exampleFix":"// before\nquarkus.kubernetes.env-vars.node.name=metadata.name,field=metadata.name\n// after\nquarkus.kubernetes.env-vars.node.name=field=metadata.name","handlingStrategy":"validation","validationCode":"if (value != null && field != null) throw new IllegalStateException(\"Env var '\" + name + \"' cannot have both literal value and field reference\");","typeGuard":"static boolean hasSingleValueSource(String value, String field) {\n    return (value == null) != (field == null);\n}","tryCatchPattern":"try { KubernetesEnvBuildItem.create(name, secret, configmap, value, field, explicit); } catch (IllegalArgumentException e) { /* choose value XOR field */ }","preventionTips":["One of value or field per env var — never both","When adding field=..., remove the old literal value","Lint quarkus.kubernetes.env-vars entries for dual keys"],"tags":["kubernetes","env-var","config"],"backgroundTag":"env-var-source-conflict","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}