Drupal 7 Rule to save node based on fetched entity throwing EntityMalformedException if field empty So I have a rule that attempts to fetch a node using fetch entity by property, and re-save it with a new author if a user field value matches a node field value upon user login. 

It works just fine unless it can't find a match, in which case I get the following error: 


  EntityMalformedException: Missing bundle property on entity of type
  node. in entity_extract_ids()


I'm kind of surprised I get this error if the value doesn't exist, but now I need a workaround. 

Is there some condition I can add here to prevent the error, or am I looking at removing the "fetch entity by property", and adding a db_query()?
Well I wound up writing code to fetch the entity:

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'my_content_type')
  -&gt;propertyCondition('status', NODE_PUBLISHED)
  -&gt;fieldCondition('field_my_field', 'value', $some_value, '=')
  -&gt;range(0, 1);
$result = $query-&gt;execute();


I then wound up using $result to update the target node's author:

if($result) {
  $eid=current($result['node']);
  $node = node_load($eid-&gt;nid);
  $node-&gt;uid = $account-&gt;uid;
  node_save($node);
}


I wonder if there's a method to query the database for a single entity? That would save the "hassle" of adding a range, then having to extract the desired value from the $result array.