{"record":{"id":"c6a73266abd629b7","repo":"bazelbuild/bazel","slug":"illegal-use-of-no-prefix-on-non-boolean-option","errorCode":null,"errorMessage":"Illegal use of 'no' prefix on non-boolean option: %s","messagePattern":"Illegal use of 'no' prefix on non-boolean option: (.+?)","errorType":"exception","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/OptionsParserImpl.java","lineNumber":795,"sourceCode":"      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          }\n          // \"no<optionname>\" signifies a boolean option w/ false value\n          unconvertedValue = \"0\";\n        }\n      }\n      parsedOptionName = name;\n    } else {\n      throw new OptionsParsingException(\"Invalid options syntax: \" + arg, arg);\n    }\n\n    // Do not recognize internal options, which are treated as if they did not exist.\n    if (lookupResult == null || shouldIgnoreOption(lookupResult.definition)) {\n      if (isFirstRoundOfParsing) {\n        return new ParsedOptionDescriptionOrIgnoredArgs(Optional.empty(), Optional.of(arg));","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java#L777-L813","documentation":"The parser accepts '--no<optionName>' only as the false-spelling of a boolean-syntax option. When stripping 'no' yields a known option but that option does not use boolean value syntax (usesBooleanValueSyntax() is false), the 'no' prefix is illegal and this error is thrown, because non-boolean options require an explicit value.","triggerScenarios":"Passing '--no' + the name of a non-boolean option, e.g. `--nostamp` when stamp takes a value, or `--nocompilation_mode` where the option expects an enum/string argument.","commonSituations":"Assuming every Bazel flag has a --no variant; carrying over muscle memory from flags like --noincremental_external_repository or --nobuild_python_zip; a real flag name that legitimately starts with 'no' being typed correctly but shadowed by this rule.","solutions":["Check the flag's type with `bazel help <command>` — only boolean-syntax flags support the --no prefix","For value-taking flags, pass an explicit value: --stamp=no or --stamp=false rather than --nostamp","If the flag genuinely starts with 'no' and is non-boolean (legacy naming), pass it with its value as usual — only the stripped-match path triggers this error"],"exampleFix":"# before\nbazel build --nostamp //...\n# after (stamp takes an int/tristate value)\nbazel build --stamp=no //...","handlingStrategy":"validation","validationCode":"// If you own the option surface, expose boolean-ness so callers can pre-validate\nstatic boolean supportsNoPrefix(OptionDefinition d) {\n  return d.usesBooleanValueSyntax();\n}\n// Callers: only emit \"--no\" + name when supportsNoPrefix(def) is true.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `bazel help` output: value flags show a placeholder, boolean flags do not","For non-boolean flags always pass an explicit value","Avoid blanket '--no' + name generation in tooling"],"tags":["bazel","options","boolean-flag","flag-parsing"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}