MigrationLookup's skipOnEmpty() means you can't provide a default value if a lookup fails

Created on 1 June 2018, over 6 years ago
Updated 8 March 2024, 10 months ago

MigrationLookup::transform() calls a helper method, skipOnEmpty(), and that throws a MigrateSkipProcessException if the source value for the lookup is empty.

But that means that a process pipeline can't specify a default value if a source row .

eg:

process:
  uid:
    -
      plugin: migration_lookup
      migration: users
      source: author
    - 
      # we never get here is 'author' is empty
      plugin: default_value
      default_value: 1

In particular, this means that a stub row created for an outer migration's lookup will always skip processing here, because the stub row creation won't provide a source value for the inner lookup.

Feature request
Status

Closed: won't fix

Version

11.0 🔥

Component
Migration 

Last updated 4 days ago

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • last update over 1 year ago
    Custom Commands Failed
  • @jhedstrom opened merge request.
  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    Custom Commands Failed
  • 🇺🇸United States jhedstrom Portland, OR

    I've made an attempt to implement the direction in #2. Attaching a patch for use with composer.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    CC failure.

  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    29,554 pass
  • 🇮🇳India suresh prabhu parkala Bangalore

    Tried to fix the custom command failure. Please review.

  • Status changed to Closed: won't fix over 1 year ago
  • 🇺🇸United States mikelutz Michigan, USA

    We are not adding any new exceptions-as-signals here. MigrateSkipProcessException is in the process of being deprecated in Allow process plugins to stop further processing on a pipeline RTBC . I confess it is odd and probably wrong that migration_lookup throws a skip process exception if the input is empty, yet will return a null when the lookup fails with a non-empty value, it does seem like we should treat both situations the same. Regardless, for BC and maintenance reasons we don't intend to make further changes to the migration lookup plugin. It is expected to be deprecated and replaced with a new one that handles this and other situations better in #3246666: Deprecate migrate_lookup and replace with cleaner process plugin and that issue would be the place to make sure we include more consistent handling here. This will allow us to build a whole new plugin without worrying about backwards compatibility for these situations.

  • 🇳🇱Netherlands batigolix Utrecht

    In case someone needs a default value when using the migration_lookup plugin: This is the work around that I am using:

      eid_lookup:
        plugin: migration_lookup
        source: user
        no_stub: true
        migration: user
      entity_id:
        plugin: default_value
        source: '@eid_lookup'
        default_value: 1
    
Production build 0.71.5 2024