EntityMalformedException: Missing bundle property on entity of type ... in entity_extract_ids() (line 7734 of \includes\common.inc) SOLVED

Writting my own entity types admin page forced me to solve some annoying not understood for me and not documented errors and "missing bundle" is one of them. Received after editing the existing entity. Why the system do not set it mannually? To not go longer in thoughts when we need the result FAST the easy fix is...

So you MUST add bundle value to the entity editing form ( myentity_form() ) and for security reasons better use 'value' type instead of 'hidden'.

$form['bundle'] = array('#type' => 'value', '#value' => $entity->bundle);