{"record":{"id":"906474079ad196e8","repo":"presidentbeef/brakeman","slug":"invalid-format-options-invalid-options-inspect","errorCode":null,"errorMessage":"\nInvalid format options: #{invalid_options.inspect}","messagePattern":"\nInvalid format options: #(.+?)","errorType":"exception","errorClass":"OptionParser::ParseError","httpStatus":null,"severity":"error","filePath":"lib/brakeman/options.rb","lineNumber":376,"sourceCode":"          options[:absolute_paths] = true\n        end\n\n        opts.on \"--github-repo USER/REPO[/PATH][@REF]\", \"Output links to GitHub in markdown and HTML reports using specified repo\" do |repo|\n          options[:github_repo] = repo\n        end\n\n        opts.on \"--text-fields field1,field2,etc.\", Array, \"Specify fields for text report format\" do |format|\n          valid_options = [:category, :category_id, :check, :code, :confidence, :cwe, :file, :fingerprint, :line, :link, :message, :render_path]\n\n          options[:text_fields] = format.map(&:to_sym)\n\n          if options[:text_fields] == [:all]\n            options[:text_fields] = valid_options\n          else\n            invalid_options = (options[:text_fields] - valid_options)\n\n            unless invalid_options.empty?\n              raise OptionParser::ParseError, \"\\nInvalid format options: #{invalid_options.inspect}\"\n            end\n          end\n        end\n\n        opts.on \"-w\",\n          \"--confidence-level LEVEL\",\n          [\"1\", \"2\", \"3\"],\n          \"Set minimal confidence level (1 - 3)\" do |level|\n\n          options[:min_confidence] =  3 - level.to_i\n        end\n\n        opts.on \"--compare FILE\", \"Compare the results of a previous Brakeman scan (only JSON is supported)\" do |file|\n          options[:previous_results_json] = File.expand_path(file)\n        end\n\n        opts.separator \"\"\n        opts.separator \"Configuration files:\"","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/presidentbeef/brakeman/blob/649e678d0a46bda0e7c35874fa7af5d16e19b4f1/lib/brakeman/options.rb#L358-L394","documentation":"`--text-fields f1,f2,...` customizes which columns appear in the plain-text report. Each name must be one of the fixed valid set (:category, :category_id, :check, :code, :confidence, :cwe, :file, :fingerprint, :line, :link, :message, :render_path) or the single pseudo-value `all`. Any other symbol is collected into an array and raises `OptionParser::ParseError` listing the invalid options.","triggerScenarios":"Running `brakeman --text-fields message,confidence,severity` (`severity` is not a valid field), misspelling a field name, or using a field name that exists in other Brakeman output formats but not in the text-report whitelist (e.g. `warning_code` or `user_input`). Passing exactly `all` is fine and expands to every valid field.","commonSituations":"Building a compact CI log output and guessing field names from the JSON report schema; reusing a field list from another tool's config; field sets written against an older/newer Brakeman whose valid set differs.","solutions":["Remove or correct the invalid names so every entry is in the valid set, e.g. `brakeman --text-fields confidence,file,message`.","If unsure which names are supported, use `--text-fields all` to include every valid field.","Re-run without `--text-fields` to fall back to the default text report if the customization is optional."],"exampleFix":"# before\nbrakeman --text-fields message,confidence,severity\n# => OptionParser::ParseError: Invalid format options: [:severity]\n\n# after (valid fields only)\nbrakeman --text-fields message,confidence,check\n# or simply everything\nbrakeman --text-fields all","handlingStrategy":"validation","validationCode":"# Ruby, whitelist before use\nVALID_TEXT_FIELDS = %i[category category_id check code confidence cwe file fingerprint line link message render_path].freeze\n\nfields = requested.map(&:to_sym)\nfields = VALID_TEXT_FIELDS if fields == [:all]\nunknown = fields - VALID_TEXT_FIELDS\nraise ArgumentError, \"Invalid text fields: #{unknown.join(', ')}\" unless unknown.empty?\n\nBrakeman.run :app_path => app, :text_fields => fields","typeGuard":null,"tryCatchPattern":"begin\n  Brakeman::Options.parse!(['--text-fields', fields.join(',')])\nrescue OptionParser::ParseError => e\n  if e.message.include?('Invalid format options')\n    warn \"#{e.message} — falling back to --text-fields all\"\n    retry with ['--text-fields', 'all']\n  end\n  raise\nend","preventionTips":["Copy field names from `brakeman --help` / the option's documented set rather than from JSON report keys — the two schemas differ.","Use `--text-fields all` when the exact set does not matter.","Wrap user-supplied field lists in a whitelist check before they reach the CLI."],"tags":["brakeman","cli","text-report","validation","option-parsing"],"backgroundTag":"invalid-option-value","analyzedSha":"649e678d0a46bda0e7c35874fa7af5d16e19b4f1","analyzedAt":"2026-08-21T18:43:10.938Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}