{"record":{"id":"1cd82bf03975a95d","repo":"Jguer/yay","slug":"invalid-option-s","errorCode":null,"errorMessage":"invalid option '%s'","messagePattern":"invalid option '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/parser/parser.go","lineNumber":173,"sourceCode":"\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc (a *Arguments) addOP(op string) error {\n\tif a.Op != \"\" {\n\t\treturn errors.New(gotext.Get(\"only one operation may be used at a time\"))\n\t}\n\n\ta.Op = op\n\n\treturn nil\n}\n\nfunc (a *Arguments) addParam(option, arg string) error {\n\tif !isArg(option) {\n\t\treturn errors.New(gotext.Get(\"invalid option '%s'\", option))\n\t}\n\n\tif isOp(option) {\n\t\treturn a.addOP(option)\n\t}\n\n\ta.CreateOrAppendOption(option, strings.Split(arg, \",\")...)\n\n\tif isGlobal(option) {\n\t\ta.Options[option].Global = true\n\t}\n\n\treturn nil\n}\n\nfunc (a *Arguments) AddArg(options ...string) error {\n\tfor _, option := range options {\n\t\terr := a.addParam(option, \"\")","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/parser/parser.go#L155-L191","documentation":"addParam in pkg/settings/parser/parser.go validates each option string against isArg before processing. If the option is not a recognized flag/operation of the parser, it returns 'invalid option '%s''. This is the parser's generic rejection of unknown CLI flags.","triggerScenarios":"AddArg, parseShortOption or parseLongOption encounters an option string not present in the parser's known-argument table; e.g. passing '-Z' or '--nonsense' to the Arguments parser.","commonSituations":"Typos in flags (-Q vs -q); flags supported by pacman but not by this tool/version; flags removed or renamed in a version change; forwarding arbitrary user flags into the parser programmatically.","solutions":["Check the flag spelling against the tool's documented options (and pacman's for pacman-style flags).","Run with --help or the man page to list valid options for this version.","Remove the unsupported flag; if it came from an alias or script, fix the alias/script definition.","Upgrade or downgrade the tool if the flag exists in another version."],"exampleFix":"// before\nyay -Ss firefox --noconfirmr   # typo'd flag\n// after\nyay -Ss firefox --noconfirm","handlingStrategy":"validation","validationCode":"// Validate options against the parser's known set before calling AddArg\nfor _, opt := range myFlags {\n    if !parser.IsArg(opt) { // if exported; otherwise keep a local allowlist\n        return fmt.Errorf(\"unsupported option %q\", opt)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := args.AddArg(opt); err != nil {\n    if strings.Contains(err.Error(), \"invalid option\") {\n        return usageError(fmt.Sprintf(\"unknown flag %s — see --help\", opt))\n    }\n    return err\n}","preventionTips":["Copy flags from the tool's --help/man page rather than memory","Watch pacman version changes: options get added, renamed, or removed","Keep an allowlist of valid flags when forwarding user input into the parser","Double-check short vs long flag spellings (-q vs --quiet)"],"tags":["cli","arguments","parser","invalid-flag"],"backgroundTag":"invalid-cli-argument","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}