{"record":{"id":"ce3876d5bca6fc7b","repo":"bazelbuild/bazel","slug":"unrecognized-option-s-s","errorCode":null,"errorMessage":"Unrecognized option: %s%s","messagePattern":"Unrecognized option: (.+?)(.+?)","errorType":"exception","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/OptionsParserImpl.java","lineNumber":822,"sourceCode":"      }\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));\n      }\n      String suggestion;\n      // Do not offer suggestions for short-form options.\n      if (arg.startsWith(\"--\")) {\n        suggestion = SpellChecker.didYouMean(arg, getAllValidArgs());\n      } else {\n        suggestion = \"\";\n      }\n      throw new OptionsParsingException(\"Unrecognized option: \" + arg + suggestion, arg);\n    }\n\n    if (unconvertedValue == null) {\n      // Special-case boolean to supply value based on presence of \"no\" prefix.\n      if (lookupResult.definition.usesBooleanValueSyntax()) {\n        unconvertedValue = booleanValue ? \"1\" : \"0\";\n      } else if (lookupResult.definition.getType().equals(Void.class)) {\n        // This is expected, Void type options have no args.\n      } else if (nextArgs.hasNext()) {\n        // \"--flag value\" form\n        unconvertedValue = nextArgs.next();\n        commandLineForm.append(\" \").append(unconvertedValue);\n      } else {\n        throw new OptionsParsingException(\"Expected value after \" + arg);\n      }\n    }\n\n    if (lookupResult.fromFallback) {","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/OptionsParserImpl.java#L804-L840","documentation":"After syntax parsing succeeded, no option definition matched the name (or the matched option is internal and treated as nonexistent). On the final parsing round the parser throws with the offending token plus, for '--' long flags, a SpellChecker 'did you mean' suggestion computed against all valid option names for the command.","triggerScenarios":"Passing a flag that does not exist for the current command, a flag gated behind an unreleased/removed Bazel version, a typo'd long flag, or an internal (OptionMetadataTag.INTERNAL) option used externally.","commonSituations":"Upgrading/downgrading Bazel where a flag was renamed or deleted (e.g. --experimental_* churn); using a command-specific flag on the wrong command (build flag on 'query'); flags defined only when a rule/repository is loaded.","solutions":["Apply the 'Did you mean' suggestion printed in the message if present","Run `bazel help <command>` and confirm the flag exists for that command in your Bazel version","If the flag comes from .bazelrc, use command-scoped sections (build:..., common:...) or `bazel --ignore_all_rc_files` to bisect which rc line is at fault","For renamed flags, migrate to the new name; use Bazel's incompatible-flag migration guides"],"exampleFix":"# before\nbazel build --compilationMode=fastbuild //...\n# after (use snake_case as registered, or the suggestion shown)\nbazel build --compilation_mode=fastbuild //...","handlingStrategy":"try-catch","validationCode":"// Programmatically: confirm a flag exists for the command before building argv\nOptionsParser parser = OptionsParser.builder().optionsClasses(...).build();\nboolean exists = parser.getOptionsDescription(/* includeDeprecated */)\n    .stream().anyMatch(o -> o.getName().equals(flagName));","typeGuard":null,"tryCatchPattern":"Catch OptionsParsingException around parse; when the message starts with 'Unrecognized option:', extract the did-you-mean suffix and offer it to the user (or auto-apply it in interactive tooling).","preventionTips":["Pin the Bazel version in CI so the flag set is stable","Scope .bazelrc entries by command (build:, test:, common:) to avoid cross-command flags","Run `bazel help command | grep flag` when adding flags to scripts"],"tags":["bazel","options","unknown-flag","flag-parsing","typo","bazelrc"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}