{"record":{"id":"7e990a0c0c68de57","repo":"presidentbeef/brakeman","slug":"invalid-github-repository-format","errorCode":null,"errorMessage":"Invalid GitHub repository format","messagePattern":"Invalid GitHub repository format","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/brakeman.rb","lineNumber":350,"sourceCode":"      when /\\.sarif$/i\n        :to_sarif\n      when /\\.sonar$/i\n        :to_sonar\n      when /\\.github$/i\n        :to_github\n      else\n        :to_text\n      end\n    end\n  end\n  private_class_method :get_formats_from_output_files\n\n  def self.get_github_url options\n    if github_repo = options[:github_repo]\n      full_repo, ref = github_repo.split '@', 2\n      name, repo, path = full_repo.split '/', 3\n      unless name && repo && !(name.empty? || repo.empty?)\n        raise ArgumentError, \"Invalid GitHub repository format\"\n      end\n      path.chomp '/' if path\n      ref ||= 'master'\n      ['https://github.com', name, repo, 'blob', ref, path].compact.join '/'\n    else\n      nil\n    end\n  end\n  private_class_method :get_github_url\n\n  #Output list of checks (for `-k` option)\n  def self.list_checks options\n    require 'brakeman/scanner'\n\n    add_external_checks options\n\n    if options[:list_optional_checks]\n      $stderr.puts \"Optional Checks:\"","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/presidentbeef/brakeman/blob/649e678d0a46bda0e7c35874fa7af5d16e19b4f1/lib/brakeman.rb#L332-L368","documentation":"`--github-repo` tells Brakeman to build clickable source links into GitHub from warning locations. The value must be of the form `owner/repo[/subpath][@ref]` (e.g. `myorg/myapp@main`). `Brakeman.get_github_url` splits the value on `@` then `/`; if it cannot extract a non-empty owner and repo segment, it raises `ArgumentError`.","triggerScenarios":"Passing a bare repo name (`--github-repo myapp`), an empty segment (`--github-repo myorg/` or `--github-repo /myapp`), or — most commonly — a full URL like `--github-repo https://github.com/myorg/myapp`, which splits into `['https:', '', 'github.com/myorg/myapp']` and fails the non-empty repo check.","commonSituations":"CI configuration where the repository URL from an environment variable or the pipeline's repo setting (`$CI_REPOSITORY_URL`, `$GITHUB_REPOSITORY_URL`) is pasted directly into `--github-repo`; copy-pasting the browser URL instead of the `owner/repo` slug; forgetting the repo half when only intending the owner.","solutions":["Use the plain `owner/repo` slug: `--github-repo myorg/myapp`.","Optionally add a subpath and/or ref: `--github-repo myorg/myapp/spec@develop` (ref defaults to `master` when omitted).","If the value comes from CI variables, strip the URL prefix first, e.g. use `$GITHUB_REPOSITORY` (already `owner/repo`) instead of the full repository URL."],"exampleFix":"# before\nbrakeman --github-repo https://github.com/myorg/myapp   # => ArgumentError: Invalid GitHub repository format\n\n# after\nbrakeman --github-repo myorg/myapp\n# or with branch ref\nbrakeman --github-repo myorg/myapp@main","handlingStrategy":"validation","validationCode":"# Ruby, validate before passing to Brakeman\ndef valid_github_repo?(value)\n  value.match?(%r{\\A[\\w.-]+/[\\w.-]+(/[^@]*)?(@\\S+)?\\z})\nend\n\nrepo = ENV['GITHUB_REPOSITORY'] # already 'owner/repo'\nraise ArgumentError, 'Invalid GitHub repository format' unless valid_github_repo?(repo)","typeGuard":null,"tryCatchPattern":"begin\n  Brakeman.run :app_path => app, :github_repo => repo\nrescue ArgumentError => e\n  abort \"#{e.message} — pass owner/repo (optionally /path@ref), not a full URL.\" if e.message == 'Invalid GitHub repository format'\n  raise\nend","preventionTips":["Store and pass the `owner/repo` slug (e.g. $GITHUB_REPOSITORY), never the full repository URL.","Add a regex gate in wrapper scripts: ^owner/repo(/path)?(@ref)?$.","Remember the ref is optional and defaults to `master`; include it explicitly when your default branch is `main`."],"tags":["brakeman","github","link-generation","option-validation","cli","argument-error"],"backgroundTag":"invalid-option-value","analyzedSha":"649e678d0a46bda0e7c35874fa7af5d16e19b4f1","analyzedAt":"2026-08-21T18:43:10.938Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}