presidentbeef/brakeman · error · OptionParser::ParseError
Invalid format options: #{invalid_options.inspect}
Error message
Invalid format options: #{invalid_options.inspect} What it means
`--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.
Source
Thrown at lib/brakeman/options.rb:376
options[:absolute_paths] = true
end
opts.on "--github-repo USER/REPO[/PATH][@REF]", "Output links to GitHub in markdown and HTML reports using specified repo" do |repo|
options[:github_repo] = repo
end
opts.on "--text-fields field1,field2,etc.", Array, "Specify fields for text report format" do |format|
valid_options = [:category, :category_id, :check, :code, :confidence, :cwe, :file, :fingerprint, :line, :link, :message, :render_path]
options[:text_fields] = format.map(&:to_sym)
if options[:text_fields] == [:all]
options[:text_fields] = valid_options
else
invalid_options = (options[:text_fields] - valid_options)
unless invalid_options.empty?
raise OptionParser::ParseError, "\nInvalid format options: #{invalid_options.inspect}"
end
end
end
opts.on "-w",
"--confidence-level LEVEL",
["1", "2", "3"],
"Set minimal confidence level (1 - 3)" do |level|
options[:min_confidence] = 3 - level.to_i
end
opts.on "--compare FILE", "Compare the results of a previous Brakeman scan (only JSON is supported)" do |file|
options[:previous_results_json] = File.expand_path(file)
end
opts.separator ""
opts.separator "Configuration files:"View on GitHub (pinned to 649e678d0a)
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.
Example fix
# before brakeman --text-fields message,confidence,severity # => OptionParser::ParseError: Invalid format options: [:severity] # after (valid fields only) brakeman --text-fields message,confidence,check # or simply everything brakeman --text-fields all
Defensive patterns
Strategy: validation
Validate before calling
# Ruby, whitelist before use
VALID_TEXT_FIELDS = %i[category category_id check code confidence cwe file fingerprint line link message render_path].freeze
fields = requested.map(&:to_sym)
fields = VALID_TEXT_FIELDS if fields == [:all]
unknown = fields - VALID_TEXT_FIELDS
raise ArgumentError, "Invalid text fields: #{unknown.join(', ')}" unless unknown.empty?
Brakeman.run :app_path => app, :text_fields => fields Try / catch
begin
Brakeman::Options.parse!(['--text-fields', fields.join(',')])
rescue OptionParser::ParseError => e
if e.message.include?('Invalid format options')
warn "#{e.message} — falling back to --text-fields all"
retry with ['--text-fields', 'all']
end
raise
end Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Comparison file doesn't exist
- Cannot specify output format if multiple output files specif
- Invalid GitHub repository format
- Could not find specified check#{missing.length > 1 ? 's' : '
- Minimum age must be 1-15 days.
AI-assisted analysis of presidentbeef/brakeman@649e678d0a (2026-08-21).
Data as JSON: /api/errors/906474079ad196e8.
Report an issue: GitHub.