hi! When I am logged as admin i receive this message. It appears only on frontpage and on node pages. On user account everything is ok.

"EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of (...)\sites\all\modules\entity\includes\entity.wrapper.inc).

Comments

Kolo’s picture

Status: Active » Closed (fixed)
Anonymous’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

I have the same error and it occurs whether or not I am logged-in as admin or user, or am just browsing as anonymous:

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of /data/disk/fast1/static/platforms/d7group1/sites/all/modules/entity/includes/entity.wrapper.inc).

This error causes EVERY non-admin page except the home page to to redirect to an error screen, so the site is down in the worst way. I filed a bug report today under your stable release, updated to the current dev and the same problem exists. What can I do to help you solve this error. Can't disable it or I won't have a site. Thanks.

This site the error occurs on is running BOA 2.0.6-dev and has nginx as a server, thus no apache mod_rewrite. I HAVE cleared all caches many times and the problem still exists.

The site is running core 7.21 and I updated Organic Groups to 2.1, Ubercart to 3.4 and comment_notify to 1.2 - all latest stable today, just before I noticed the problem, but I'm not 100% sure that his problem began after his morning's update.

The problem is NOt with Ubercart - the errors still occur with all Ubercart disabled. Now I have determined that the sites that produce this error all have Organic Groups and Entity enabled, and the sites on the same platform that do NOT produce this error have entity enabled but do NOT have Organic Groups enabled. Could this be a problem with entity and OG and not necessarily a problem with entity and core 7.21?

This site also has i18n and entity translation enabled.

lias’s picture

Issue tags: +OG, +entity

Similar issue with OG 2.1 and Entity 1.0

EntityMetadataWrapperException: Unknown data property og_group_ref__og_membership. in EntityStructureWrapper->getPropertyInfo() (line 339 of C:\Inetpub\wwwroot\domain\sites\all\modules\entity\includes\entity.wrapper.inc).

Posted here: http://drupal.org/node/1519884#comment-7236252

betz’s picture

Same issue.

OG-2.1
entity dev

Here /user is working fine, but when i open the menu item edit or add form, i get this error.

TheoRichel’s picture

I am having this similar error with the combo Rooms - Entity:

Notice: Trying to get property of non-object in commerce_product_line_item_populate() (regel 1352 van /storage/web/public/sites/www.slapeninyerseke.nl/sites/all/modules/commerce/modules/product_refere...).
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (regel 744 van /storage/web/public/sites/www.slapeninyerseke.nl/sites/all/modules/entity/includes/entity.wrapper.inc).

This is beyond me, I hope this is not off topic here

gabrielmachadosantos’s picture

I've updated the OG module from 7.x-2.2 to 7.x-2.3 and the problem is gone.

aluzzardi’s picture

Issue tags: -OG, -entity +entity API

I have a similar error after a Search for some page, when it found results I get this error, when it not found, set me to page for advanced search

I not using OG module

Alexander Allen’s picture

Category: bug » support
Priority: Critical » Major

As I said in #1673220, it seems to me this is an issue with other modules passing the wrong parameters to EntityDrupalWrapper->set(), then failing Entity API's validation criteria. The onus is on the contrib or custom implementer to pass Entity API valid data...

aluzzardi, could you please provide a full call stack? I'd like to take a look at it if possible.

Thanks

hazit’s picture

I get this too - but only when deleting content.

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of profiles\openatrium\modules\contrib\entity\includes\entity.wrapper.inc).

It is a totally fresh instal with version 7x-1.2

hazit’s picture

Category: support » bug
Priority: Major » Critical

updated - Now I can neither create nor delete content. I get the following error each time:

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of \profiles\openatrium\modules\contrib\entity\includes\entity.wrapper.inc).

If we should be posting these under other issue pages, I am not sure how I would find out which ones they should be - but am happy to do that too instead of posting them here.

Cheers,

H

kae76’s picture

I have reopen your issue you posted in Open Atrium issue queue: https://drupal.org/node/2107919#comment-7949419 as similar to mine.

arnoldbird’s picture

I'm seeing this problem when working with the registration module. You can recreate it by registering a user for some entity, then deleting the user. When you try to view the registrations for the entity, you get the error mentioned in the original bug report.

If I dump the registration entity I see that it's out of synch with the registration table in the database. A user ID that (correctly) is NULL in the registration table is still set in the registration entity, and so Drupal goes looking for a user account that no longer exists. So I figured it must be a caching problem. Sure enough, if I delete the associated entry in the cache_entity_registration table, the problem goes away.

In other words, one possible cause of this error is failure to clear an entry in a cache table, though it's probably not the only possible cause.

daniel-san’s picture

I am seeing the exact same issue as Arnoldbird with the Registration module. I am only replying here to verify his comment in #12, but I will take this over to Registration issue queue as that would probably be the proper thing to do.

psychobyte’s picture

I get this error as well. It never tells you the offending line of code where the ->set() method is called. Not even in the apache logs. Is there a way to make it easy to trace where the problem line of code is?

mossy2100’s picture

Issue summary: View changes

I've just posted https://drupal.org/node/2214417, may be a duplicate.
If so, I apologise.

2ndmile’s picture

Just to add my cause and fix. I was using entity_metadata_wrapper('node', $node) where $node was being set by the node_load function. The problem was the nid was invalid, so $node was empty which threw the error. I just added if (empty($node)) { return; } and all works as expected. It would be nice to have more of an indication of where the error was taking place. I luckily had a hunch.

docans’s picture

I also had the same error on commerce kickstart after enable my own custom module. Everything works fine except on the cart page. It was working initially. Here is the error Code

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /home/html/drupal-site/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).

Any idea

paulovg12’s picture

I have exactly the same issue by do cans on the same line 736 of entity.wrapper.inc It happens when I create content for an OG one of (Post, Gallery, Blog, Poll). My OG is tied up with a Calendar Event and Entity Registration. The Entity Registration works, the other content types allow me to fill in the content as usual then fail with the error while saving. There was an update on Entity API yesterday and the behaviour changed somewhat but the error still remains.

paulovg12’s picture

Issue tags: -entity API +entity API OG

I have the same issue, I deleted some of the previous contents, I believe there was an update a few days ago.
Mine use to work fine before the deletion and update. Entity API was updated yesterday but my error remains.

message is below:

Type node
Date Wednesday, April 9, 2014 - 02:49
User pvgervasio
Location https://secure144.inmotionhosting.com/~dacapo5/rc/node/add/photos?og_gro...
Referrer https://secure144.inmotionhosting.com/~dacapo5/rc/node/add/photos?og_gro...
Message EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /home/dacapo5/public_html/rc/sites/all/modules/entity/includes/entity.wrapper.inc).
Severity error
Hostname 218.186.196.224
Operations

I did some testing and temporarily modified the I added the following in the entity wrapper inc file :

  public function set($value) {
   if (!$this->validate($value)) {
       drupal_set_message('Entity Wrapper: Invalid data value given: '. $value);
       drupal_set_message('Entity Wrapper: Invalid data value given info [type]: '. $value->info['type']);
       drupal_set_message('Entity Wrapper: Invalid data value given info: '. $value->info);
       drupal_set_message('Entity Wrapper: Invalid data value given type: '. $value->type);
       drupal_set_message('Entity Wrapper: Invalid data value given id: '. $value->id);
       drupal_set_message('Entity Wrapper: Invalid data value given data: '. $value->data);
       throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
    }

it gave me this

Entity Wrapper: Invalid data value given: Array
Entity Wrapper: Invalid data value given info [type]:
Entity Wrapper: Invalid data value given info:
Entity Wrapper: Invalid data value given type:
Entity Wrapper: Invalid data value given id:
Entity Wrapper: Invalid data value given data:

The value Array in $value is either empty array or the string "Array"
It seems like there is some syntax error somewhere.

drupalninja99’s picture

I have this same issue after upgrading OG from 1.6 to 2.6. Content tagged with OG is erroring out.

drupalninja99’s picture

I used to have a group_audience field but that went away for some reason.

hazit’s picture

Here I am again. New clean instal of Open Atrium 7.x-2.18, Entity API 7.x-1.5 and the same old error:

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of profiles/openatrium/modules/contrib/entity/includes/entity.wrapper.inc).

In my case it occurs when adding default OA content type 'event'. All I did was add a field to the content type and it sent me on this death-spiral again. I removed the offending field but the error persists.

Surely I should be able to add a field to a content type without locking the thing up - I am still a novice but this seems like basic Drupal 101.

On a previous site instal i had to delete the 'Groups Audience' field to solve this problem, but this then caused a bunch of other problems.

1 - am i even posting this to the right cue?
2 - is there a simple, stable fix for this that anyone is aware of?
3 - is there any hope that modules like this might become more stable?

Cheers and many thanks

H

1kenthomas’s picture

Title: Error - EntityMetadataWrapperException: Invalid data value given(...)in EntityDrupalWrapper->set() (line 744 of... » Malformed Entities Throw Exception, better validation needed
Issue tags: -entity API OG +entity API OG validation

See #19 for helpful code (though: test for NULL before you do anything else!)

This issue is reported under many different queues and this report thus may be a duplicate; I'm unsure where best to give it a home.

The core of the issue seems to be that malformed entities/fields will throw an exception in entity.inc, blocking page load without a very explanatory error message.

1kenthomas’s picture

Priority: Critical » Major

Status change: don't think it's Critical, but appears major.

1kenthomas’s picture

Title: Malformed Entities Throw Exception, better validation needed » Malformed Entities Throw Exception, better error reporting needed
corentin.crouvisier’s picture

Hi, I have the same issue with eck when I try to delete an entity content (with VBO or deletion button).
type : eck entity
EntityMetadataWrapperException : Invalid data value given. Be sure it matches the required data type and format. dans EntityDrupalWrapper->set() (ligne 736 dans public_html/sites/all/modules/entity/includes/entity.wrapper.inc).

Before deleting The field_collection field, error was :
type : field_collection_item
EntityMalformedException: Missing bundle property on entity of type dossier. in entity_extract_ids() (line 7734 of public_html/includes/common.inc).

The error occurred after a bug in my code saving the "dossier" entity (eck with form api) that caused a fatal sql error even if I solved it.

1kenthomas’s picture

@corentin.crouvisier:

You problem looks to be due to using an improperly formatted field in an entity-- which then produces a validation error when going through Entity's wrapper module.

As it stands, this thread is about the possible need for better debugging information in the module code, not your coding issue per se. The code in reply 19 may help you debug, though it seems you're pretty close.

Hope that helps!

rv0’s picture

Similar issue after a client did a messed up update with OG.

Problem in my case was the og_membership table had not been updated.
to fix, I did this:
UPDATE `og_membership` SET group_type = 'node', field_name = 'og_group_ref' WHERE entity_type = 'node'
UPDATE `og_membership` SET group_type = 'node', field_name = 'og_user_node' WHERE entity_type = 'user'

(in reality, the migrate upgrade of OG had not been executed correctly, so check that first if you have the same problem.)

esolitos’s picture

Hi everyone, I have version 7.x-1.5 and I have the same problem.
Now I'm trying to debug why this error shows up.

Here's our situation:
We have a content type: Open Article which has a field of type "Term Reference" (Named: field_op_section_term) displayed as a Select box.
When I add a new node works fine for all the options in the select EXCEPT for two of them.
If i try to add a node with an option that "does not fire this bug" and then I set the "bugged" option everything is fine, so i think that the problem is only in the creation of a node.
This is a new situation, since the website is up and running since a while.

While trying to debug I found something weird!
If in EntityMetadataWrapper->validate() I return a TRUE without any check, everything goes well! The node gets added successfully and no error is reported anywhere.
But there's more: from this time on using the incriminated taxonomy term (that was previously "bugged") will not fire an error anymore, it will validate and the node will be added successfully, (and yes I restored the original validate() function.)
I can't really find a reason for that: anyone has any suggestion?

Marlon

esolitos’s picture

Ok, we manage to solve our mysterious BUG, apparently it was related with NodeQueue.
We haven't figured out exactly what it was yet, but disabling this functionality solved our problem.

+1 anyway to the request to have more details on the error. It was not very clear what was causing the exception!

zmove’s picture

I have the same bug (same line 736 error, same file entity.wrapper.inc), but nothing related to OG for me.

It happens on a fresh install with just some must have modules (display suite, views, i18n etc..., only heavy used modules), and I got that error when I try to add a menu link to a menu...

hiramanpatil’s picture

I am getting error when assigning mulitple roles to the user. If use has single role then page loads properly. But as soon as I assign second role to the user and logs in with same user from front-end it shows below error message:-

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /PROJECT_PATH/sites/all/modules/entity/includes/entity.wrapper.inc).

Please let me know if anyone has same issue or any solution.

bdupls’s picture

This error appeared on a site that I have been working on for a while. I then created a new local Commons site and created a new content type and added the new content type to OG field settings. And this error appeared when I created new content. Only my error occurs on line 736
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 736 of /Users/xxx/Sites/xxx/sites/all/modules/entity/includes/entity.wrapper.inc).
If I include this line on line 736 to cater for empty fields the error changes to line 335 at nikita #11 states he gets.
if (empty($node)) { return; }

People on this link are having similar problems on this site
https://www.drupal.org/node/1519884

rcodina’s picture

Workaround by @esolitos on #29 worked for me. Thanks!

Just edit function validate on entity/includes/entity.wrapper.inc and add a "return TRUE;" as first function instruction.

texas-bronius’s picture

See more at #1621226: Entity Metadata Wrapper: Add field information to exception message on validation exception including a patch that can be more helpful to developers.

rcodina’s picture

scottAtRoot802’s picture

#28 worked for me, although I also needed to include profiles.

UPDATE `og_membership` SET group_type = 'node', field_name = 'og_group_ref' WHERE entity_type = 'node'
UPDATE `og_membership` SET group_type = 'node', field_name = 'og_user_node' WHERE entity_type = 'user'
UPDATE `og_membership` SET group_type = 'node', field_name = 'og_group_ref' WHERE entity_type = 'profile2'
Arne Slabbinck’s picture

#29 also worked for me .. doesn't feel right though :P

Fool2’s picture

There are a ton of unrelated issues in this issue. The underlying issue is that the error message is not clear at all about the problem:

    if (!$this->validate($value)) {
      throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
    }

In entity.wrapper.inc, there are several validate() failures that could cause this that make it inaccurate. (this error is thrown when the validate() returns false)

 if (isset($value) && !entity_property_verify_data_type($value, $this->type)) {
      return FALSE;
    }
    // Only proceed with further checks if this is not a list item. If this is
    // a list item, the checks are performed on the list property level.
    if (isset($this->info['parent']) && $this->info['parent'] instanceof EntityListWrapper) {
      return TRUE;
    }
    if (!isset($value) && !empty($this->info['required'])) {
      // Do not allow NULL values if the property is required.
      return FALSE;
    }
    return !isset($this->info['validation callback']) || call_user_func($this->info['validation callback'], $value, $this->info);

This seems to be due to how validate() is structured... I suspect throwing an exception from validate() is a bad idea as it may be used elsewhere in entity API where it would be inappropriate. I am afraid that changing this would break too many implementations. We may be able to add an extra optional argument to validate() which includes error reporting, and allow validate to throw exceptions of its own if that argument is provided. I do not know enough about the other uses of this function to make a recommendation, however-- I only found this issue because I was debugging a bad entity import and found the error message to be super ambiguous. It wasn't even helpful in locating the code location it was being called from, as this message is returned from two different places in the entity wrappers alone.

apaderno’s picture

Issue tags: -entity API OG validation