chatwoot/chatwoot · error · ArgumentError

Select at least one data type to import.

Error message

Select at least one data type to import.

What it means

Raised by both Freshdesk and Intercom credentials validators as an ArgumentError when @import_types is blank. DataImport::IMPORT_TYPES is %w[contacts conversations], and an import that selects nothing has no work to do and cannot run the per-type probe API calls, so the validator rejects it up front.

Source

Thrown at app/services/data_imports/freshdesk/credentials_validator.rb:20

  def initialize(domain:, api_key:, import_types:)
    @domain = domain
    @api_key = api_key.to_s.strip
    @import_types = Array(import_types).compact_blank
  end

  def perform
    validate_parameters!
    client.list_contacts(per_page: 1) if @import_types.include?('contacts')
    client.list_tickets(per_page: 1) if @import_types.include?('conversations')
    {}
  end

  private

  def validate_parameters!
    raise ArgumentError, 'Freshdesk domain is required.' if @domain.blank?
    raise ArgumentError, 'Freshdesk API key is required.' if @api_key.blank?
    raise ArgumentError, 'Select at least one data type to import.' if @import_types.blank?

    invalid_types = @import_types - DataImport::IMPORT_TYPES
    raise ArgumentError, "Unsupported import types: #{invalid_types.join(', ')}" if invalid_types.present?

    DataImports::Freshdesk::Client.normalize_domain(@domain)
  end

  def client
    @client ||= DataImports::Freshdesk::Client.new(domain: @domain, api_key: @api_key)
  end
end

View on GitHub (pinned to ed230f9bc0)

Solutions

  1. Select at least one of 'contacts' or 'conversations' and resubmit.
  2. In code, pass import_types: %w[contacts] or %w[contacts conversations].
  3. Default the form/UI selection so the request cannot go out with an empty list.

Example fix

# before
DataImports::Freshdesk::CredentialsValidator.new(domain: domain, api_key: api_key, import_types: []).perform # raises

# after
DataImports::Freshdesk::CredentialsValidator.new(domain: domain, api_key: api_key, import_types: %w[contacts conversations]).perform
Defensive patterns

Strategy: validation

Validate before calling

types = Array(params[:import_types]).presence || %w[contacts conversations]
raise ArgumentError, 'Select at least one data type to import.' if types.blank?

Prevention

When it happens

Trigger: Calling the validator with import_types: nil, import_types: [] or import_types: '' (checkboxes for contacts/conversations both unchecked).

Common situations: UI form submitted with no data-type checkbox selected; front-end defaults failed to preselect a type; programmatic caller forgot to set import_types when creating the DataImport record.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of chatwoot/chatwoot@ed230f9bc0 (2026-08-21). Data as JSON: /api/errors/7b78896b097ea34d. Report an issue: GitHub.