I'm learning how to create migrations in D8. However, I have this annoying issue where my migration is listed when I execute drush migrate-status but the total and unprocessed values are shown as N/A, shown below:
Group: JSON People (people) Status Total Imported Unprocessed Last imported
nodetest Idle N/A 0 N/A
people_data Idle 1000 0 1000
My json config is as follows:
id: nodetest
description: Testing for a node migration
label: Node Test
migration_group: people
source:
plugin: url
data_fetcher_plugin: http
data_parser_plugin: json
urls:
- 'http://api.tvmaze.com/search/shows?q=family'
# path: 'http://api.tvmaze.com/search/shows?q=family'
item_selector: /
# identifierDepth: 1
ids:
show:
id:
type: integer
fields:
-
name: name
label: Name of show
selector: name
process:
type:
plugin: default_value
default_value: page
title: name
destination:
plugin: 'entity:node'
I have been unable to figure out what the issue is some I get figures rather than the N/A output I'm currently getting.
Any help, please!
UPDATE: I found I was incorrectly using show as the item_selector. Infact, the json from the api service does not have a "label" which refers to all the json objects, as shown below:
So, I remove item_selector from the yml data and I then get 10 instead of N/A in the total column of the nodetest migration.
The problem now is I get Invalid argument supplied for foreach() DataParserPluginBase.php:121 [warning]
warnings (1 for each json object).
And, when I attempt to migrate, I get the following error:
Invalid argument supplied for foreach() DataParserPluginBase.php:121 [warning]
Invalid argument supplied for foreach() DataParserPluginBase.php:121 [warning]
TypeError: Argument 2 passed to Drupal\migrate\Row::__construct() must be of the type array, null given, called in [error]
/var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php on line 357 in Drupal\migrate\Row->__construct() (line 101 of
/var/www/d8/core/modules/migrate/src/Row.php) #0 /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(357):
Drupal\migrate\Row->__construct(Array, NULL)
#1 /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(330): Drupal\migrate\Plugin\migrate\source\SourcePluginBase->next()
#2 [internal function]: Drupal\migrate\Plugin\migrate\source\SourcePluginBase->rewind()
#3 /var/www/d8/core/modules/migrate/src/MigrateExecutable.php(188): FilterIterator->rewind()
#4 /usr/local/share/drush/includes/drush.inc(721): Drupal\migrate\MigrateExecutable->import()
#5 /usr/local/share/drush/includes/drush.inc(712): drush_call_user_func_array(Array, Array)
#6 /var/www/d8/modules/contrib/migrate_tools/migrate_tools.drush.inc(317): drush_op(Array)
#7 [internal function]: _drush_migrate_tools_execute_migration(Object(Drupal\migrate\Plugin\Migration), 'nodetest', Array)
#8 /var/www/d8/modules/contrib/migrate_tools/migrate_tools.drush.inc(272): array_walk(Array, '_drush_migrate_...', Array)
#9 /usr/local/share/drush/includes/command.inc(422): drush_migrate_tools_migrate_import('nodetest')
#10 /usr/local/share/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#11 /usr/local/share/drush/includes/command.inc(199): drush_command('nodetest')
#12 /usr/local/share/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#13 /usr/local/share/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#14 /usr/local/share/drush/drush.php(12): drush_main()
#15 {main}.
TypeError: Argument 2 passed to Drupal\migrate\Row::__construct() must be of the type array, null given, called in /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php on line 357 in /var/www/d8/core/modules/migrate/src/Row.php on line 101 #0 /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(357): Drupal\migrate\Row->__construct(Array, NULL)
#1 /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php(330): Drupal\migrate\Plugin\migrate\source\SourcePluginBase->next()
#2 [internal function]: Drupal\migrate\Plugin\migrate\source\SourcePluginBase->rewind()
#3 /var/www/d8/core/modules/migrate/src/MigrateExecutable.php(188): FilterIterator->rewind()
#4 /usr/local/share/drush/includes/drush.inc(721): Drupal\migrate\MigrateExecutable->import()
#5 /usr/local/share/drush/includes/drush.inc(712): drush_call_user_func_array(Array, Array)
#6 /var/www/d8/modules/contrib/migrate_tools/migrate_tools.drush.inc(317): drush_op(Array)
#7 [internal function]: _drush_migrate_tools_execute_migration(Object(Drupal\migrate\Plugin\Migration), 'nodetest', Array)
#8 /var/www/d8/modules/contrib/migrate_tools/migrate_tools.drush.inc(272): array_walk(Array, '_drush_migrate_...', Array)
#9 /usr/local/share/drush/includes/command.inc(422): drush_migrate_tools_migrate_import('nodetest')
#10 /usr/local/share/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#11 /usr/local/share/drush/includes/command.inc(199): drush_command('nodetest')
#12 /usr/local/share/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#13 /usr/local/share/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#14 /usr/local/share/drush/drush.php(12): drush_main()
#15 {main}
TypeError: Argument 2 passed to Drupal\migrate\Row::__construct() must be of the type array, null given, called in /var/www/d8/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php on line 357 in Drupal\migrate\Row->__construct() (line 101 of /var/www/d8/core/modules/migrate/src/Row.php).
Drush command terminated abnormally due to an unrecoverable error.
item_selector
is correct and returning items?