diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index 5376fee2442ebc74cf593accbf68c3033ee8f2f6..5d96cec4107e97955bde586a54a7f83501c84e13 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -630,10 +630,11 @@ class SAMLBuilder
      */
     public function addContact(array $details): void
     {
-        Assert::oneOf($type, ['technical', 'support', 'administrative', 'billing', 'other']);
+        Assert::notNull($details['contactType']);
+        Assert::oneOf($details['contactType'], ['technical', 'support', 'administrative', 'billing', 'other']);
 
         $e = new \SAML2\XML\md\ContactPerson();
-        $e->setContactType($type);
+        $e->setContactType($details['contactType']);
 
         if (!empty($details['attributes'])) {
             $e->setContactPersonAttributes($details['attributes']);