8 – How to make subprocess & migration_lookup plugins behave consistently with single and multiple items arrays

I have a JSON that can hold single or multi values arrays and I can’t make subprocess + migration_lookup behave consistently. It correctly imports the nodes in all cases, but it adds the reference to the imported nodes (entity reference field) only when I have more than 1 item in my array.

my JSON can looks like this:

"behaviour": (
          {
            "name": "behaviour name",
            "description": "behaviour description"
          }
        )

or like this:

"behaviour": (
          {
            "name": "behaviour name",
            "description": "behaviour description"
          },
          {
            "name": "another behaviour name",
            "description": "another behaviour description"
          }
        )

the process part of my migration config:

  field_behaviour:
    plugin: sub_process
    source: behaviour_array
    process:
      target_id:
        plugin: migration_lookup
        migration: import_behaviours_json
        source: name