I am migrating a field in a node to a paragraph. I am trying to only create the paragraphs where the field has values. That field is an entity reference to another node.

  plugin: d7_node
  node_type: my_node
      plugin: get
      source: node_er_field/0/target_id
      plugin: get
      source: nid
      plugin: default_value
      default_value: node
      plugin: skip_on_empty
      method: row
      source: '@target_id'
      message: 'node skipped'
      plugin: get
      source: node_er_field
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: paragraph_er
migration_dependencies: null

When I run the migration, I get a strange reported result though. Of the first two nodes, one has something in the field, and one doesn't. drush mim group_paragraph_field_node --limit=2 Processed 3 items (2 created, 0 updated, 0 failed, 1 ignored)

When I look at messages. The skip_on_empty message appears. But the row that it supposedly skipped is still created. I can't for the life of me understand why this is happening. The row method is being fired. I've tried every permutation I can think of in terms of doing the skip_on_empty, within the same pipeline or like this one. With the target id or just with the field as is. I've tried another custom plugin skip_on_empty_array. Either its 2 created and 0 or 1 ignored, but I always get 2 paragraphs out of it.

I've gotten skip_on_empty to work in other contexts. I don't understand why it is not working here. Had a hard time finding a similar example as well.

Any thoughts?

  • "But the field that it supposedly skipped is still created" that should be the row instead of field i think as you have "method: row" for skip_on_empty. Also may be check if '@target_id' in that case is really empty as defined in api.drupal.org/api/drupal/… (empty string, NULL, FALSE, 0, '0', or an empty array)
    – izus
    Mar 30, 2021 at 8:42
  • Thanks izus, you are correct on row instead of field. Edited that. I did check that it was really empty. Good suggestion though.
    – Adrained
    Mar 31, 2021 at 16:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.