Error messages are getting better with them now being logged and duplicates not being shown, but with entityreferences there is a problem. If you get error message that tells that an entity is bad because of entityreference field Y is null, it is impossible to figure out which item from source caused that.

So to give an example. Let's say we have a required author entityreference field that's getting imported. Now the error message tells that item failed to import because author field can not be null.

This does not tell what value was bad. To fix the problem with the source or with wrong mapping as is suggested in the error message the end user needs to know the original value with what we were unable to find a matching entity.

Comments

mikran created an issue. See original summary.

megachriz’s picture

Agreed. The foremost goal of this exception is to distinguish it from an empty value so the hash value of the feeds item can be emptied, so Feeds can try to import the reference again on the next import (see #2989789: Reset hash when an entity reference wasn't found). But it would indeed be useful to know what value failed to import.

ReferenceNotFoundException should probably receive the bad value. Then either EntityReference::setTarget() should set a message or we need to find out a way to pass the bad value to the validation error message generated in EntityProcessorBase::entityValidate().

Patches are welcome.

mikran’s picture

Status: Active » Needs review
StatusFileSize
new3.14 KB

Here is a patch. Patch also fixes deprecated warnings from the related unit test.

Status: Needs review » Needs work

The last submitted patch, 3: ReferenceNotFoundException-message-2998799-3.patch, failed testing. View results

mikran’s picture

Status: Needs work » Needs review
StatusFileSize
new2.72 KB
new1.31 KB

rollback unit test changes for 8.7

megachriz’s picture

@mikran
Patch looks good. I noticed that the message only shows up in the UI. I think it would be useful to log it as well.

About the message: I think it is missing a word. Should it be "Referenced entity not found for field foo with value 2900172"?

Let me know what you think!

mikran’s picture

Yes I agree. Here's updated patch.

mikran’s picture

StatusFileSize
new3.08 KB
new2.39 KB

and wrong patch.

  • MegaChriz committed 89f2d01 on 8.x-3.x authored by mikran
    Issue #2998799 by mikran: Fixed ReferenceNotFoundException should be...
megachriz’s picture

Status: Needs review » Fixed

I've been running this patch for a few days on a live site now. I think it's working okay, though I only think it should be logged as a warning instead of an error. Validation failures are also logged as warning.

Committed #8 with that one change.

Status: Fixed » Closed (fixed)

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