Skip to content

Conversation

@BigG1947
Copy link

We have 2 situation when raised errors without handling:

  1. Empty CSV and model has force_encoding: 'auto'
    In this case encoding detected automatically by
    def dynamic_encoding(data)
      CharDet.detect(data)['encoding']
    end

But if data is empty string '' result will be nil. data.force_encoding(encoding_name) where data is empty string and encoding_name is nil raise TypeError: no implicit conversion of nil into String

  1. When we have invalid csv in which values exceeded headers activerecord_import gem raised ArgumentError:
 raise ArgumentError, "Number of values (#{arr.length}) exceeds number of columns (#{columns.length})"

We can handle it in collection_action and return flash message to users

@senid231 senid231 merged commit e6eef78 into activeadmin-plugins:master Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants