{"record":{"id":"9902fdfa6bf16d62","repo":"wpscanteam/wpscan","slug":"the-option-opt-to-long-is-required","errorCode":null,"errorMessage":"The option #{opt.to_long} is required","messagePattern":"The option #(.+?) is required","errorType":"exception","errorClass":"OptParseValidator::NoRequiredOption","httpStatus":null,"severity":"error","filePath":"lib/opt_parse_validator.rb","lineNumber":148,"sourceCode":"\n        begin\n          @results[opt.to_sym] = opt.normalize(opt.validate(files_data[opt.to_sym].to_s))\n        rescue StandardError => e\n          # Adds the long option name to the message\n          # And raises it as an OptParseValidator::Error if not already one\n          # e.g --proxy Invalid Scheme format.\n          raise e.is_a?(Error) ? e.class : Error, \"#{opt.to_long} #{e}\"\n        end\n      end\n    end\n\n    # Ensure that all required options are supplied\n    # Should be overriden to modify the behavior\n    #\n    # @return [ Void ]\n    def post_processing\n      @opts.each do |opt|\n        raise NoRequiredOption, \"The option #{opt.to_long} is required\" if opt.required? && !@results.key?(opt.to_sym)\n\n        next if opt.required_unless.empty? || @results.key?(opt.to_sym)\n\n        fail_msg = 'One of the following options is required: ' \\\n                   \"#{opt.to_long}, --#{opt.required_unless.join(', --').tr('_', '-')}\"\n\n        raise NoRequiredOption, fail_msg unless opt.required_unless.any? do |sym|\n          @results.key?(sym)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":130,"sourceCodeEnd":162,"githubUrl":"https://github.com/wpscanteam/wpscan/blob/62c9cef471de90095f6b42245a11d0f8172d19c9/lib/opt_parse_validator.rb#L130-L162","documentation":"Raised by OptParseValidator::OptParser#post_processing (lib/opt_parse_validator.rb:148) after argv and config files are parsed: an option registered with required: true never produced a value in @results (no CLI flag, no config-file entry, no default). The message names the long form of the missing option. WPScan vendors this validator and runs it on every invocation through WPScan::ParsedCli, so the scan aborts before any HTTP request is made.","triggerScenarios":"Calling parser.results(argv) (or wpscan) with argv that omits a required option; registering OptBase options with required: true and supplying the value only in a config file whose key is misspelled or not loaded (keys must be snake_case symbols matching option.to_sym); an alias that maps to the required option without providing it; default value nil so @results stays empty.","commonSituations":"Scripts/CI invoking wpscan without the mandatory flag; a typo in ~/.config/wpscan/scan.yml (e.g. 'URL:' instead of 'url:'); config file in an unscanned location (loader only reads XDG dirs, ~/.wpscan, and ./.wpscan); a wpscan upgrade introducing a new required option that old scripts don't pass.","solutions":["Supply the named option on the command line exactly as shown, e.g. wpscan --url https://example.com","Or persist it in a config file under its snake_case symbol: echo 'url: https://example.com' > ~/.config/wpscan/scan.yml","Check the exact spelling/long form with wpscan --help or --full-help (dashes on CLI, underscores in config)","If embedding the gem, pass the option inside the argv array given to the option parser instead of setting it afterwards"],"exampleFix":"# before\n$ wpscan\n# => raise NoRequiredOption: The option --url is required\n\n# after\n$ wpscan --url https://example.com","handlingStrategy":"try-catch","validationCode":"# Before calling parser.results(argv): ensure every option you registered\n# with required: true is present (CLI or config files)\nrequired_syms = %i[url] # symbols matching OptBase#to_sym of your required options\nmissing = required_syms.reject { |sym| argv.include?(\"--#{sym.to_s.tr('_', '-')}\") }\nabort \"Missing required option(s): #{missing.map { |s| '--' + s.to_s.tr('_', '-') }.join(' ')}\" unless missing.empty?","typeGuard":null,"tryCatchPattern":"begin\n  options = parser.results(ARGV)\nrescue OptParseValidator::NoRequiredOption => e\n  abort e.message # or print parser.full_help and exit non-zero\nend","preventionTips":["Encode required options once in a shared constant used by both the parser registration and your preflight check","Prefer config files (scan.yml/scan.json) with snake_case keys for values that never change between runs","In CI, assert on the error message early with a dry-run instead of discovering it mid-pipeline"],"tags":["cli","option-parsing","ruby","wpscan","usage-error"],"backgroundTag":"missing-required-cli-option","analyzedSha":"62c9cef471de90095f6b42245a11d0f8172d19c9","analyzedAt":"2026-08-21T17:10:47.902Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}