{"record":{"id":"7b78896b097ea34d","repo":"chatwoot/chatwoot","slug":"select-at-least-one-data-type-to-import","errorCode":null,"errorMessage":"Select at least one data type to import.","messagePattern":"Select at least one data type to import\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":422,"severity":"error","filePath":"app/services/data_imports/freshdesk/credentials_validator.rb","lineNumber":20,"sourceCode":"  def initialize(domain:, api_key:, import_types:)\n    @domain = domain\n    @api_key = api_key.to_s.strip\n    @import_types = Array(import_types).compact_blank\n  end\n\n  def perform\n    validate_parameters!\n    client.list_contacts(per_page: 1) if @import_types.include?('contacts')\n    client.list_tickets(per_page: 1) if @import_types.include?('conversations')\n    {}\n  end\n\n  private\n\n  def validate_parameters!\n    raise ArgumentError, 'Freshdesk domain is required.' if @domain.blank?\n    raise ArgumentError, 'Freshdesk API key is required.' if @api_key.blank?\n    raise ArgumentError, 'Select at least one data type to import.' if @import_types.blank?\n\n    invalid_types = @import_types - DataImport::IMPORT_TYPES\n    raise ArgumentError, \"Unsupported import types: #{invalid_types.join(', ')}\" if invalid_types.present?\n\n    DataImports::Freshdesk::Client.normalize_domain(@domain)\n  end\n\n  def client\n    @client ||= DataImports::Freshdesk::Client.new(domain: @domain, api_key: @api_key)\n  end\nend\n","sourceCodeStart":2,"sourceCodeEnd":32,"githubUrl":"https://github.com/chatwoot/chatwoot/blob/ed230f9bc068e7a13dd5c0404d5465a204b68d4c/app/services/data_imports/freshdesk/credentials_validator.rb#L2-L32","documentation":"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.","triggerScenarios":"Calling the validator with import_types: nil, import_types: [] or import_types: '' (checkboxes for contacts/conversations both unchecked).","commonSituations":"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.","solutions":["Select at least one of 'contacts' or 'conversations' and resubmit.","In code, pass import_types: %w[contacts] or %w[contacts conversations].","Default the form/UI selection so the request cannot go out with an empty list."],"exampleFix":"# before\nDataImports::Freshdesk::CredentialsValidator.new(domain: domain, api_key: api_key, import_types: []).perform # raises\n\n# after\nDataImports::Freshdesk::CredentialsValidator.new(domain: domain, api_key: api_key, import_types: %w[contacts conversations]).perform","handlingStrategy":"validation","validationCode":"types = Array(params[:import_types]).presence || %w[contacts conversations]\nraise ArgumentError, 'Select at least one data type to import.' if types.blank?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default the form to at least one selected data type.","Use Array() around the param so a single string still becomes a one-element list.","Disable the submit button while the selection is empty."],"tags":["data-import","freshdesk","intercom","argument-error","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"ed230f9bc068e7a13dd5c0404d5465a204b68d4c","analyzedAt":"2026-08-21T12:45:25.920Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}