{"record":{"id":"c3a674044d7a4738","repo":"GoogleContainerTools/jib","slug":"invalid-environment-variable-definition-environ","errorCode":null,"errorMessage":"Invalid environment variable definition: + environmentVariable","messagePattern":"Invalid environment variable definition: \\+ environmentVariable","errorType":"validation","errorClass":"BadContainerConfigurationFormatException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java","lineNumber":210,"sourceCode":"        builder.setRetries(containerConfigurationTemplate.getContainerHealthRetries());\n      }\n      imageBuilder.setHealthCheck(builder.build());\n    }\n\n    if (containerConfigurationTemplate.getContainerExposedPorts() != null) {\n      imageBuilder.addExposedPorts(\n          portMapToSet(containerConfigurationTemplate.getContainerExposedPorts()));\n    }\n\n    if (containerConfigurationTemplate.getContainerVolumes() != null) {\n      imageBuilder.addVolumes(volumeMapToSet(containerConfigurationTemplate.getContainerVolumes()));\n    }\n\n    if (containerConfigurationTemplate.getContainerEnvironment() != null) {\n      for (String environmentVariable : containerConfigurationTemplate.getContainerEnvironment()) {\n        Matcher matcher = ENVIRONMENT_PATTERN.matcher(environmentVariable);\n        if (!matcher.matches()) {\n          throw new BadContainerConfigurationFormatException(\n              \"Invalid environment variable definition: \" + environmentVariable);\n        }\n        imageBuilder.addEnvironmentVariable(matcher.group(\"name\"), matcher.group(\"value\"));\n      }\n    }\n\n    imageBuilder.addLabels(containerConfigurationTemplate.getContainerLabels());\n    imageBuilder.setWorkingDirectory(containerConfigurationTemplate.getContainerWorkingDir());\n    imageBuilder.setUser(containerConfigurationTemplate.getContainerUser());\n  }\n\n  /**\n   * Converts a map of exposed ports as strings to a set of {@link Port}s (e.g. {@code\n   * {\"1000/tcp\":{}}} -> {@code Port(1000, Protocol.TCP)}).\n   *\n   * @param portMap the map to convert\n   * @return a set of {@link Port}s\n   */","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java#L192-L228","documentation":"Each entry in the container configuration's 'Env' array must match ENVIRONMENT_PATTERN (NAME=value). Jib throws BadContainerConfigurationFormatException for entries that don't match, since it cannot split the variable name from its value.","triggerScenarios":"Calling JsonToImageTranslator.toImage with a container configuration whose environment entries lack '=', are empty strings, have an empty name, or contain malformed separators (e.g. 'NAME:' or 'NAME').","commonSituations":"Configs written by tooling that stores env as JSON objects instead of the Docker 'NAME=value' string array; hand-edited container config JSON; entries with only a name and no value; accidental whitespace or missing '=' after copy-paste.","solutions":["Correct the offending Env entry to 'NAME=value' format in the container configuration JSON","Pre-validate each entry against a NAME=value regex before calling toImage","Catch BadContainerConfigurationFormatException, log the offending entry, and repair or drop it before retrying"],"exampleFix":"// before\n\"Env\": [\"PATH\"]\n// after\n\"Env\": [\"PATH=/usr/local/bin:/usr/bin\"]","handlingStrategy":"validation","validationCode":"Pattern p = Pattern.compile(\"(?<name>[^=]+)=(?<value>.*)\");\nfor (String env : config.getContainerEnvironment()) {\n  if (!p.matcher(env).matches()) throw new IllegalArgumentException(\"bad env entry: \" + env);\n}","typeGuard":null,"tryCatchPattern":"try { JsonToImageTranslator.toImage(manifest, config); } catch (BadContainerConfigurationFormatException e) { /* fix offending Env entry to NAME=value and retry */ }","preventionTips":["Ensure container config Env uses the Docker 'NAME=value' string array format","Validate each entry contains '=' and a non-empty name","Sanitize env arrays produced by non-Docker build tooling before translation"],"tags":["jib","container-config","environment-variable","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}