Currently, the "Missing data values" exception is a black box that is needlessly frustrating to debug.
EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 83 of /var/www/public/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
Instead, let's increase the verbosity of the error so developers have context about what went wrong.
EntityMetadataWrapperException: Missing data values on type "node" property "nid" with ID "false" from FUNCTION in /var/www/src/sites/all/modules/custom/MODULE/MODULE.module line 20 in EntityMetadataWrapper->value() (line 84 of /var/www/public/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
Comment | File | Size | Author |
---|---|---|---|
#29 | entity-data_value_exception_verbose-2482795-29.patch | 1.36 KB | vitalius2009 |
#26 | interdiff.txt | 1.74 KB | Spokje |
#26 | entity-data_value_exception_verbose-2482795-26.patch | 1.29 KB | Spokje |
Comments
Comment #1
FluxSauce CreditAttribution: FluxSauce commentedComment #2
FluxSauce CreditAttribution: FluxSauce commentedSorry, got a little too far up the callstack, this will be more actionable.
Comment #3
joelpittetBig +1 to this, thanks for writing this up. One question since it wasn't mentioned nor there before the patch.
Should this be translated?
Comment #4
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commentedGood call! Looking at #817160: Don't translate exceptions and it looks like no, I shouldn't be translating it. Hard habit to break! I'll do something similar to https://api.drupal.org/api/drupal/includes%21errors.inc/function/_drupal...
Comment #5
d0t101101 CreditAttribution: d0t101101 commented+1
This patch helped me to break down our cryptic EntityAPI error messages to something meaningful. Couldn't have sorted a nasty bug without it so quickly! Thanks, and hope to see this applied to the next release.
.
Comment #6
joelpittetre #3 We shouldn't translate exception messages. I just found this out today we have docs:)
https://www.drupal.org/node/608166
Comment #7
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commentedHonestly forgot about this and it fell off my radar. Friday is my contrib day, I'll re-roll!
Comment #8
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commentedRe-rolled with sprintf.
Comment #13
joelpittetMaybe -dev is broken. This shouldn't cause failures.
Comment #15
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commentedWaited a week, let's see if the test system will pass.
Comment #17
joelpittetLet's go with RTBC on that:) Random testbot failure.
Comment #18
FluxSauce CreditAttribution: FluxSauce at Four Kitchens commented¯\_(ツ)_/¯
Thanks!
Comment #19
leewillis77 CreditAttribution: leewillis77 at Upbeat Productions commentedHi;
I just tested the patch from #8 which gives me output like this:
EntityMetadataWrapperException: Missing data values on type "field_contact_firstname" property "profile2" with ID "false" from value.
That doesn't seem right - surely the field name / entity type should be the other way around, e.g.
EntityMetadataWrapperException: Missing data values on type "profile2" property "field_contact_firstname" with ID "false" from value.
If so - revised patch attached :)
Comment #20
sokru CreditAttribution: sokru at Druid commented+1 for commiting #19 or #8
Comment #21
fago+1 on giving a better error message, but I do not think it's our job to add a debug backtrace. For that other error handlers like the one from devel can be used. Besides that, in another recent addition there was a method debugIdentifierLocation() added to the wrappers - it probably makes sense to re-use this one here also to add info about the wrapper location to the exception.
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commented@fago, I thought I could access it like this
$this->debugIdentifierLocation()
but I got this error:PHP Fatal error: Call to undefined method EntityDrupalWrapper::debugIdentifierLocation() in modules/all/entity/includes/entity.wrapper.inc on line 374
$this
is defined and is an object. How do I access debugIdentifierLocation?Comment #23
FrittenKeeZ CreditAttribution: FrittenKeeZ commentedThe method EntityMetadataWrapper::debugIdentifierLocation() does not exist in the latest release of the Entity module.
Comment #24
Falco010+1 confirming patch #19 is working, thank you for saving so much headache!!!
Comment #25
emarchak CreditAttribution: emarchak at Myplanet commented@fago, given that EntityMetadataWrapper::debugIdentifierLocation() does not exist, what would be the next steps to get this patch in? Removing the backtrace?
Comment #26
SpokjeReworked patch #19 so that if the devel-module is enabled, the "verbose" information in the exception will be shown.
If not, the original Exception will be thrown.
Comment #27
SpokjeComment #28
natanmoraesFound a few issues on codesniffer. Please fix these and any other that may appear with phpcs.
Line indented incorrectly; expected 6 spaces, found 3
Whitespace found at end of line
Whitespace found at end of line
Whitespace found at end of line
Closing brace indented incorrectly; expected 3 spaces, found 6
Spaces must be used to indent lines; tabs are not allowed
Closing brace indented incorrectly; expected 4 spaces, found 1
Other than that, the patch looks good and did the trick to help debug an error
Comment #29
vitalius2009 CreditAttribution: vitalius2009 as a volunteer commentedI suggest including the name and the parents's type and id in any case, regardless whether the devel module is enabled or not. We don't enable this module on the production sites in most cases, but we need to know the reason for this weird error.
Comment #30
vitalius2009 CreditAttribution: vitalius2009 as a volunteer commentedComment #31
scotwith1tThis was SUPER helpful for me today. Had a site where the client deleted entities which were in an entity queue and the page using the queue was failing with the super-unhelpful "Missing data values" message. After trying to no avail to figure out what was happening, this patch helped me immediately figure out what the issue was, resaved the entity queue so it could stop referencing the deleted node and voilà! Thanks!
Comment #32
Normunds Lauva CreditAttribution: Normunds Lauva commentedFINALLY! Hours/days in total wasted of precious life doing desparate debugging! Thanks a lot for this!
Comment #33
denix CreditAttribution: denix as a volunteer commentedShall we expect a new release? Thanks for this!
Comment #34
apadernoComment #35
TR CreditAttribution: TR commentedFrom #21:
Yes, it would be super useful to have this information, but @fago's review in #21 has never been addressed, which seems to be why this issue never progressed.
The patch in #29 should be changed to use
debugIdentifierLocation()
as @fago said. The patch should also be changed to useddebug_backtrace()
from the devel module rather than rolling our own solution. I would be fine with checking to see if theddebug_backtrace()
function exists (rather than checking for the devel module) - if it does then useddebug_backtrace()
, else use the backtrace code that's already in the patch. That addresses the concern raised in #29 about getting some of this more detailed information on sites that aren't running devel.