{"record":{"id":"596728040757535c","repo":"bazelbuild/bazel","slug":"invalid-options-syntax-s","errorCode":null,"errorMessage":"Invalid options syntax: %s","messagePattern":"Invalid options syntax: (.+?)","errorType":"exception","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/OptionsParserImpl.java","lineNumber":782,"sourceCode":"    boolean booleanValue = true;\n    String parsedOptionName = \"\";\n\n    if (arg.length() == 2) { // -l  (may be nullary or unary)\n      lookupResult = getWithFallback(OptionsData::getFieldForAbbrev, arg.charAt(1), fallbackData);\n      booleanValue = true;\n\n    } else if (arg.length() == 3 && arg.charAt(2) == '-') { // -l-  (boolean)\n      lookupResult = getWithFallback(OptionsData::getFieldForAbbrev, arg.charAt(1), fallbackData);\n      booleanValue = false;\n\n    } else if (arg.startsWith(\"--\")) { // --long_option\n\n      int equalsAt = arg.indexOf('=');\n      int nameStartsAt = 2;\n      String name =\n          equalsAt == -1 ? arg.substring(nameStartsAt) : arg.substring(nameStartsAt, equalsAt);\n      if (name.trim().isEmpty()) {\n        throw new OptionsParsingException(\"Invalid options syntax: \" + arg, arg);\n      }\n      unconvertedValue = equalsAt == -1 ? null : arg.substring(equalsAt + 1);\n      lookupResult = getWithFallback(OptionsData::getOptionDefinitionFromName, name, fallbackData);\n\n      // Look for a \"no\"-prefixed option name: \"no<optionName>\".\n      if (lookupResult == null && name.startsWith(\"no\")) {\n        name = name.substring(2);\n        lookupResult =\n            getWithFallback(OptionsData::getOptionDefinitionFromName, name, fallbackData);\n        booleanValue = false;\n        if (lookupResult != null) {\n          if (!lookupResult.definition.usesBooleanValueSyntax()) {\n            throw new OptionsParsingException(\n                \"Illegal use of 'no' prefix on non-boolean option: \" + arg, arg);\n          }\n          if (unconvertedValue != null) {\n            throw new OptionsParsingException(\"Unexpected value after boolean option: \" + arg, arg);\n          }","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java#L764-L800","documentation":"Thrown while parsing a '--'-prefixed token when the option name between '--' and '=' is empty or only whitespace, e.g. '--=value' or '--   =x'. The long-option branch extracts the name after the two dashes; an empty name has no corresponding option definition so parsing cannot continue.","triggerScenarios":"Passing a token like `--=foo`, `-- =foo`, or a shell variable that expands to nothing between the dashes, e.g. `--${EMPTY_VAR}=value`.","commonSituations":"Script-generated command lines where a flag-name variable is unset or empty; accidental deletion of the flag name when editing a command; copy-paste artifacts like '--=true'.","solutions":["Inspect the exact token reported in the message and restore the missing flag name","In scripts, guard flag construction: skip or error when the name variable is empty (e.g. [ -n \"$name\" ] before emitting --$name=$value)","Enable shell strictness (set -u / nounset) so unset variables fail at generation time"],"exampleFix":"# before\nbazel build --${FLAG_NAME}=opt //...\n# after\n[ -n \"$FLAG_NAME\" ] || { echo 'FLAG_NAME unset' >&2; exit 1; }\nbazel build --${FLAG_NAME}=opt //...","handlingStrategy":"validation","validationCode":"# Reject tokens with an empty flag name before invoking\nfor arg in \"$@\"; do\n  case \"$arg\" in\n    --[=\\ ]*|--=*) echo \"Empty option name in: $arg\" >&2; exit 2;;\n  esac\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build flags as a single '--name=value' token so an empty name is impossible","Fail scripts on unset variables (set -u)","Echo the final argv before execution during debugging"],"tags":["bazel","options","flag-parsing","cli","shell-scripting"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}