diff --git a/comment_limit.module b/comment_limit.module
index 74e2480..e9f05de 100644
--- a/comment_limit.module
+++ b/comment_limit.module
@@ -80,8 +80,15 @@ function comment_limit_form_comment_form_alter(&$form, FormStateInterface $form_
     $entity->bundle(),
     $field_name
   );
-  $field_id = $field_config->id();
-  $field_label = $field_config->getLabel();
+
+  if ($field_config instanceof FieldConfig) {
+    $field_id = $field_config->id();
+    $field_label = $field_config->getLabel();
+  }
+  else {
+    $field_id = NULL;
+    $field_label = NULL;
+  }
 
   $definitions = DataDefinition::create('any')
     ->addConstraint('CommentFormConstraint', [
