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?
skip_on_empty
does a PHP boolean evalutation. The name might be misleading from a PHP programmers point of view, but it is a quite sensible default in the context of migration sources (empty source string, different boolean representations,..)process_dummy_field: | plugin: callback | callable: var_dump | source: my_source_field
(replace pipe with intented newline)contact_array
is not an array and as @Hudri saidskip_on_empty
will not prevent you from source passing down the wrong value to subprocess.source: my_source_field
each time, only for the first process in the chain. Also I see that you have a typo in your code can you confirm your source isName
orname
?