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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | interdiff.txt | 2.39 KB | mikran |
| #8 | ReferenceNotFoundException-message-2998799-8.patch | 3.08 KB | mikran |
| #5 | interdiff.txt | 1.31 KB | mikran |
| #5 | ReferenceNotFoundException-message-2998799-5.patch | 2.72 KB | mikran |
| #3 | ReferenceNotFoundException-message-2998799-3.patch | 3.14 KB | mikran |
Comments
Comment #2
megachrizAgreed. 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 inEntityProcessorBase::entityValidate().Patches are welcome.
Comment #3
mikran commentedHere is a patch. Patch also fixes deprecated warnings from the related unit test.
Comment #5
mikran commentedrollback unit test changes for 8.7
Comment #6
megachriz@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!
Comment #7
mikran commentedYes I agree. Here's updated patch.
Comment #8
mikran commentedand wrong patch.
Comment #10
megachrizI'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.