Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

Importing entries fails when ids are not numbers #29

Open
Coolnesss opened this issue Jul 11, 2016 · 0 comments
Open

Importing entries fails when ids are not numbers #29

Coolnesss opened this issue Jul 11, 2016 · 0 comments

Comments

@Coolnesss
Copy link

When trying to import entries from a database table where the ids are not numbers (do not match the regular expression /(d+)/). The issue exists here and here where the inappropriate regex is used.

The error is

~ craj$ contentful-importer --configuration=settings.yml import-entries
I, [2016-07-11T10:00:52.587691 #13345]  INFO -- : Remove directory threads/0 from data/threads path.
I, [2016-07-11T10:00:52.589402 #13345]  INFO -- : Processing collection: country
/Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:77:in `new_entry_name': undefined method `[]' for nil:NilClass (NoMethodError)
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:81:in `copy_entry'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:50:in `block in process_collection_files'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:49:in `glob'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:49:in `process_collection_files'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:33:in `block in split_entries'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:29:in `glob'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:29:in `split_entries'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/data_organizer.rb:19:in `execute'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/parallel_importer.rb:31:in `import_data'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/import_entries.rb:14:in `import'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/lib/contentful/importer/import_entries.rb:19:in `run'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/claide-0.8.2/lib/claide/command.rb:312:in `run'
    from /Users/craj/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/contentful-importer-0.2.2/bin/contentful-importer:12:in `<top (required)>'
    from /Users/craj/.rbenv/versions/2.3.1/bin/contentful-importer:23:in `load'
    from /Users/craj/.rbenv/versions/2.3.1/bin/contentful-importer:23:in `<main>'

I managed to fix this by changing the mentioned lines to

"#{content_type_id}_#{File.basename(entry_path, '.*').split("_").last}.json"

and

content_type_id = File.basename(entry_path).split("_").first

I'm not sure if that's the best way though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant