diff --git a/src/Transformer/Helpers/RecursiveFormatterHelper.php b/src/Transformer/Helpers/RecursiveFormatterHelper.php
index <HASH>..<HASH> 100644
--- a/src/Transformer/Helpers/RecursiveFormatterHelper.php
+++ b/src/Transformer/Helpers/RecursiveFormatterHelper.php
@@ -63,8 +63,10 @@ final class RecursiveFormatterHelper
         $idProperties = self::getIdProperties($mappings, $type);
 
         foreach ($idProperties as &$propertyName) {
-            $values[] = self::getIdValue($value[$propertyName]);
-            $propertyName = \sprintf('{%s}', $propertyName);
+            if (!empty($value[$propertyName])) {
+                $values[] = self::getIdValue($value[$propertyName]);
+                $propertyName = \sprintf('{%s}', $propertyName);
+            }
         }
         self::flattenObjectsWithSingleKeyScalars($values);
Fixing undefined access to $value[$propertyName]