InvalidArgumentException: $string ("Migration @id is busy with another operation: @status") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct()

This is happening when display($message, $type = 'status') in MigrateMessage.php (core/modules/migrate/src/MigrateMessage.php) receives a non-rendered TranslatableMarkup instance (rather than a string) as the $message from import() in MigrateExecutable.php (core/modules/migrate/src/MigrateExecutable.php, line 168). There are many instances in MigrateExecutable that call display() with a non-rendered TranslatableMarkup instance, resulting in the error above being thrown by the \Drupal::logger(), which expects a string (MigrateExecutable.php lines 127, 168, 184, 207, 284, 303, 475, 491, and 505). In some cases (such as line 284 of MigrateExecutable.php) the InvalidArgumentException prevents the migration from being set back to STATUS_IDLE (line 287), resulting in a stuck migration at STATUS_IMPORTING.

Has anyone else seen these errors?

Comments

tessmarchant created an issue. See original summary.

timodwhit’s picture

Yeah, it looks like the migration is passing a translation object instead of a string, which the logger method requires.

There seems to be a quick fix of rendering the message if instance of TranslatableMarkable before passing the messages to the logger.

It might be good to make that fix to the drupal core logger method.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

undertext’s picture

Priority: Normal » Major

This bug breaks migrations with 'ultimate_cron' module installed.
Set status to major as this is the wrong usage of Logger API.
Any contrib module with custom logger expects $message to be a string and it should be a string, not TranslatableMarkup.

lobsterr’s picture

Assigned: Unassigned » lobsterr
lobsterr’s picture

@undertext - Can you provide the steps how I can reproduce this issue ?
After investigation of the code I found the TranslatableMarkup class uses ToStringTrait which implements

  public function __toString() {
    try {
      return (string) $this->render();
    }
    catch (\Exception $e) {
      ...

    }
  }

if we convert TranslatableMarkup to string the render method will be executed and the correct string will be returned. That exactly what I see right now and I cannot reproduce this case.

wim leers’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

heddn’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

If we can reproduce this, please re-open.