gitlabhq/gitlabhq · error · ArgumentError

Unrecognized report type: #{report_type}

Error message

Unrecognized report type: #{report_type}

What it means

Ci::JobArtifact.file_types_for_report (app/models/ci/job_artifact.rb:137) looks the report_type up in Enums::Ci::JobArtifact.report_file_types and raises ArgumentError "Unrecognized report type: #{report_type}" via Hash#fetch's block. Only artifact file types flagged as reports (sast, dependency_scanning, container_scanning, dast, etc.) are keys; anything else — including valid non-report file types like trace or archive — is rejected.

Source

Thrown at app/models/ci/job_artifact.rb:137

    def self.partition_groups
      Gitlab::Database::SharedModel.using_connection(connection) do
        Gitlab::Database::PostgresPartition
          .for_parent_table(table_name)
          .map(&:list_partition_ids)
          .select(&:any?)
          .sort_by(&:min)
      end
    end

    def self.of_report_type(report_type)
      file_types = file_types_for_report(report_type)

      with_file_types(file_types)
    end

    def self.file_types_for_report(report_type)
      Enums::Ci::JobArtifact.report_file_types.fetch(report_type) { raise ArgumentError, "Unrecognized report type: #{report_type}" }
    end

    def self.associated_file_types_for(file_type)
      return unless file_types.include?(file_type)

      [file_type]
    end

    def self.erasable_file_types
      self.file_types.keys - Enums::Ci::JobArtifact.non_erasable_file_types
    end

    def self.total_size
      self.sum(:size)
    end

    def self.artifacts_size_for(project)
      self.where(project: project).sum(:size)

View on GitHub (pinned to 55ee20384a)

Solutions

  1. Pass one of the report file types: check Enums::Ci::JobArtifact.report_file_types.keys for the exact set and spelling.
  2. Match types exactly (symbol vs string) — normalize with to_sym when needed.
  3. Guard calls: only invoke of_report_type when report_file_types.key?(report_type).
  4. If you need non-report artifacts, use Ci::JobArtifact.with_file_types([...]) directly.

Example fix

# before
Ci::JobArtifact.of_report_type(:trace) # -> ArgumentError: Unrecognized report type: trace

# after
Ci::JobArtifact.of_report_type(:sast)
# or, for non-report types:
Ci::JobArtifact.with_file_types([:trace])
Defensive patterns

Strategy: validation

Validate before calling

report_type = report_type.to_sym
unless Enums::Ci::JobArtifact.report_file_types.key?(report_type)
  raise ArgumentError, "not a report type: #{report_type} (valid: #{Enums::Ci::JobArtifact.report_file_types.keys.sample(5).join(', ')}...)"
end
Ci::JobArtifact.of_report_type(report_type)

Type guard

def report_type?(value)
  Enums::Ci::JobArtifact.report_file_types.key?(value.to_s.to_sym)
end

Try / catch

begin
  Ci::JobArtifact.of_report_type(t)
rescue ArgumentError
  # unknown report type: skip or log, but never guess a substitute
  raise
end

Prevention

When it happens

Trigger: Calling Ci::JobArtifact.of_report_type(:trace), of_report_type('junit') where junit maps differently, or a typo like :sastt. Passing a String where the enum keys are Symbols (or vice versa) also misses the fetch and raises.

Common situations: Building features that iterate over artifact types and assume every file_type is a report; refactors renaming enum keys; specs using placeholder types; version upgrades that rename or remove report types.

Related errors


AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21). Data as JSON: /api/errors/220523aec84ad72f. Report an issue: GitHub.