diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
index eb9d3859648fc779fbaec02e888eebad30090cae..f9b2586bcece507954c49e248f151cc464e53d11 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
@@ -308,6 +308,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler {
 				
 				$metadata['metadata-index'] = $index;
 				$metadata['metadata-set'] = $set;
+				assert('array_key_exists("entityid", $metadata)');
 				return $metadata;
 			}
 		}