{"record":{"id":"438aa2d194fab742","repo":"bazelbuild/bazel","slug":"variable-definitions-must-be-in-the-form-of-a-nam","errorCode":null,"errorMessage":"Variable definitions must be in the form of a 'name=value' assignment","messagePattern":"Variable definitions must be in the form of a 'name=value' assignment","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":513,"sourceCode":"            + \"-\"\n            + maxValue\n            + \" range\";\n      }\n    }\n  }\n\n  /**\n   * A converter for variable assignments from the parameter list of a blaze command invocation.\n   * Assignments are expected to have the form \"name=value\", where names and values are defined to\n   * be as permissive as possible.\n   */\n  public static class AssignmentConverter extends Converter.Contextless<Map.Entry<String, String>> {\n\n    @Override\n    public Map.Entry<String, String> convert(String input) throws OptionsParsingException {\n      int pos = input.indexOf(\"=\");\n      if (pos <= 0) {\n        throw new OptionsParsingException(\n            \"Variable definitions must be in the form of a 'name=value' assignment\");\n      }\n      String name = input.substring(0, pos);\n      String value = input.substring(pos + 1);\n      return Maps.immutableEntry(name, value);\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"a 'name=value' assignment\";\n    }\n  }\n\n  /** A converter for for assignments from a string value to a float value. */\n  public static class StringToDoubleAssignmentConverter\n      extends Converter.Contextless<Map.Entry<String, Double>> {\n    private static final AssignmentConverter baseConverter = new AssignmentConverter();\n","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L495-L531","documentation":"Thrown by AssignmentConverter when a command-line variable definition does not contain a '=' character, or the '=' is the first character (position 0, meaning an empty name). The converter splits input at the first '=' to produce a Map.Entry<name, value>, so input without a usable separator cannot be parsed. It is raised as an OptionsParsingException during flag parsing.","triggerScenarios":"Passing a flag value accepted by AssignmentConverter that lacks '=' (e.g. --define=FOO or --repo_env=PATH) or starts with '=' (=VALUE, since pos <= 0 rejects position 0). Any blaze/bazel command-line option whose converter is AssignmentConverter (e.g. --define, --repo_env, --action_env in some usages) with a malformed argument.","commonSituations":"Typos in --define flags (missing '=' or space instead of '='), shell quoting that strips the '=' or splits the argument, scripts generating flag lists that emit an empty name, CI pipelines building --define args from unset environment variables.","solutions":["Fix the argument to the exact form name=value, e.g. --define=VERSION=1.2 instead of --define=VERSION.","Check shell quoting: quote the whole flag (--define=\"NAME=va lue\") so the shell does not split it.","If the value is generated from a variable, verify it is non-empty and contains '=' before passing it (echo \"$arg\" | grep '=').","Audit scripts/CI config for lines that append to --define / --repo_env without validating the name=value shape."],"exampleFix":"# before\nbazel build --define=COMPILE_MODE\n\n# after\nbazel build --define=COMPILE_MODE=OPT","handlingStrategy":"validation","validationCode":"// Java: validate assignment shape before passing as a flag value\nboolean isValidAssignment(String s) {\n  int pos = s == null ? -1 : s.indexOf(\"=\");\n  return pos > 0; // '=' present and not first char, mirroring pos <= 0 rejection\n}\nList<String> args = rawArgs.stream().filter(this::isValidAssignment).collect(toList());","typeGuard":null,"tryCatchPattern":"catch (OptionsParsingException e) when constructing the option value: log e.getMessage() (it names the malformed input path) and surface which flag argument failed; do not retry with the same string.","preventionTips":["Validate generated flag values with input.matches(\"^.+=.+$\") before invoking bazel","Quote whole flag arguments in shell scripts so '=' survives word splitting","Add a lint step in CI that greps --define/--repo_env usages for missing '='"],"tags":["options-parsing","command-line","converter","bazel"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}