How to skip empty and missing values from a migration I'm trying to skip fields that are not present in my source file or that are empty, but I keep getting "Migration failed with source plugin exception: Passed variable is not an array or object"

This is what I've tried in YML:

field_contact:
    -
      plugin: skip_on_empty
      method: process
      source: contact_array
    -
      plugin: sub_process
      source: contact_array
      process:
        target_id:
          plugin: migration_lookup
          migration: import_contact_json
          source: Name


and

field_point_of_contact:
    plugin: sub_process
    source: contact_array
    process:
      target_id:
        -  
          plugin: skip_on_empty
          method: process
          source: name
        -
          plugin: migration_lookup
          migration: registry_import_pocs_json
          source: Name


Both of them have the same output (i.e. the error described above). 

Can someone point me in the right direction, please?
It is difficult to help without seeing the structure of your source file (at least 1 sample record). But, here are some pointers:


At first glance, the error message says something about a source plugin exception. I believe the error might be stemming from the source plugin configuration.
The approach you are taking with skip on empty seems to be in the correct direction.
Depending on the data that the field contains, you might have to handle it differently. I usually add the following to debug exactly what is being received by a particular field process. Also, make sure that the value being sent to the migrate_lookup plugin is an array.


# ...
process:
  field_point_of_contact:
    - plugin: callback
      callable: print_r
      source: name
# ...



Have you tried removing the skip on empty part? I don't remember correctly, but migrate lookup might be skipping empty values by itself.
An array with empty strings is not considered empty. If your source provides values like [''], you might have to send the array through an array_filter() to remove empties.


I hope this helps. If it doesn't, you might want to share one row of fake data.