diff --git a/src/Permissions/FlagListsPermissionHandler.php b/src/Permissions/FlagListsPermissionHandler.php
index 3d08b98..baab066 100644
--- a/src/Permissions/FlagListsPermissionHandler.php
+++ b/src/Permissions/FlagListsPermissionHandler.php
@@ -49,10 +49,15 @@ class FlagListsPermissionHandler extends PermissionHandler {
     // due to the flag lists module.
     $flagLists = $this->flagListsService->getAllFlaggingCollections();
     foreach ($flagLists as $flagList) {
-      $flag = 'flag ' . $flagList->getRelatedFlag()->id();
-      $unflag = 'unflag ' . $flagList->getRelatedFlag()->id();
-      unset($all_permissions[$flag]);
-      unset($all_permissions[$unflag]);
+      if ($flagList->getRelatedFlag()) {
+        $flag = 'flag ' . $flagList->getRelatedFlag()->id();
+        $unflag = 'unflag ' . $flagList->getRelatedFlag()->id();
+        unset($all_permissions[$flag]);
+        unset($all_permissions[$unflag]);
+      } else {
+        $logger = \Drupal::logger('flag_lists');
+        $logger->error('flagging_collection ' . $flagList->getName() . ' (' . $flagList->id() . ')' . ' owned by user id ' . $flagList->getOwner()->id() . ' doesn\'t have related flag');
+      }
     }
     // Check for access for the used template as well.
     $flagTemplates = $this->flagListsService->getAllFlagForList();
