if (!empty($source_id_values)) {
      throw new MigrateException("Extra unknown items in source IDs");
    }

This is not much detail to help a developer track down a problem. The message should:

- list the unknown source IDs. Those are just the array keys in $source_id_values at that point
- state which migration is involved. This is typically called for a migration lookup, so it could be any of a number of migrations that are being used for lookups in the migration actually being run

Comments

joachim created an issue. See original summary.

pieterjanput’s picture

Correct me if i'm wrong, but I think this is fixed in 2225587.
https://www.drupal.org/project/drupal/issues/2225587#comment-12565134

quietone’s picture

@PieterJanPut, this isn't fixed yet.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

zuhair_ak’s picture

The code right now in 8.7.x is

  if (!empty($source_id_values)) {
      $var_dump = var_export($source_id_values, TRUE);
      throw new MigrateException(sprintf("Extra unknown items in source IDs: %s", $var_dump));
  }

This had the source IDs. So we should add which migration is involved?

joachim’s picture

Which migration, and which mapping.

Come to think of it, we should probably file an issue to make this standard in all processor exceptions.

rupertj’s picture

I just ran into this message while writing a migration. I had to google it to understand what it was trying to tell me, and I still didn't understand what was wrong until I set a breakpoint on where the exception was thrown and stepped through the code.

The addition of migration and mapping sounds like a good improvement. The message I got said: "Extra unknown items in source IDs: array (0 => '[redacted string value]')". Which wasn't helpful at all.

I also found the phrase "Extra unknown items" confusing. Are some unknown items ok, but it's just these extra ones that are an issue? I initially thought this was something to do with the creation of stubs due to this wording.

RumyanaRuseva’s picture

Status: Active » Needs review
StatusFileSize
new771 bytes

Here is a patch for adding the migration map table name. That should help the developers find which element of the migration has unexpected source values.

Status: Needs review » Needs work

The last submitted patch, 8: 2974274-8.patch, failed testing. View results

mitrpaka’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB
new1.08 KB

Thanks @RumyanaRuseva for the patch. Just fixed failing test.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

This looks fine to me. Tests are passing and more context is being passed in the exception.

ekes’s picture

+1 RTBC

Just applied this one, and saved me setting a breakpoint, and gave the data that I was able to find the incorrect migrate field in my migration directly.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Crediting @joachim for creating and reviewing the issue.

Committed and pushed aa577bef92 to 8.7.x and 30d14f9c2e to 8.6.x. Thanks!

  • alexpott committed aa577be on 8.7.x
    Issue #2974274 by mitrpaka, RumyanaRuseva, joachim: exception message...

  • alexpott committed 30d14f9 on 8.6.x
    Issue #2974274 by mitrpaka, RumyanaRuseva, joachim: exception message...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.