I'm working with enterprisey data where I need to migrate some data into field collections, but the reference to the parent entity (node, in this case) sometimes refers to things which don't actually exist in the Drupal data. Eventually, `entity_get_ids()` throws its good ol' frustrating and unhelpful "Missing bundle property on entity of type node."

Here's a simple patch which adds a check to Field Collection's code to throw a more useful and appropriate exception if the host entity can't be loaded. Also, usefully, this is thrown *before* the call to `entity_create()`, so no field collection values with no host entities are created.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

milos.kroulik’s picture

I have the same problem and don't know how to correct it. It affects all nodes with attached field collections. Would it be possible to post sample of your field collection migration here? Thanks a lot.

Garrett Albright’s picture

Sorry, but I don't remember which project I was working on when I reported this, or if I still have access to it. But you can see https://www.drupal.org/patch/apply for more information on how you can try applying my patch to the module in your code base. Please report back here whether it worked for you or not.

milos.kroulik’s picture

Sorry, I should have mentioned that I already applied the patch and it's working just fine. The exception is raised, indeed. I just don't know, why it's happening. Were you able to discover any causes of this error?