Fatal error because a messy upgrade migration left some traces of comment fields in the database

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "comment" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 143 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions('comment') (Line: 193)
Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions('comment') (Line: 342)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('comment', 'comment_node_bond_disclosure_report') (Line: 107)
Drupal\layout_builder\Plugin\Derivative\FieldBlockDeriver->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('broken') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('broken', Array) (Line: 100)
Drupal\Component\Plugin\PluginManagerBase->handlePluginNotFound('system_breadcrumb_block', Array) (Line: 93)
Drupal\Core\Block\BlockManager->handlePluginNotFound('system_breadcrumb_block', Array) (Line: 79)
Drupal\Component\Plugin\PluginManagerBase->createInstance('system_breadcrumb_block', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('system_breadcrumb_block') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('system_breadcrumb_block') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('system_breadcrumb_block') (Line: 45)
Drupal\block\BlockPluginCollection->get('system_breadcrumb_block') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('system_breadcrumb_block', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'system_breadcrumb_block', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'system_breadcrumb_block', Array, 'claro_breadcrumbs') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 314)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 274)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 115)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Related? Unrelated? Must be related, went away after the other was fixed.

The website encountered an unexpected error. Please try again later. Error: Call to a member function access() on null in Drupal\block\BlockAccessControlHandler->checkAccess() (line 124 of core/modules/block/src/BlockAccessControlHandler.php).

Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 314)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 274)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 115)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 716)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Here are our villains— the site has no comments, and indeed the fatal errors only started after uninstalling comment module!

$field_info['bundles'];
array(19)
comment_node_bond_disclosure_report: "comment_node_bond_disclosure_report"
comment_node_annual_financial_statement: "comment_node_annual_financial_statement"
comment_node_offical_bond_note_statement: "comment_node_offical_bond_note_statement"
comment_node_lihtc_allocations_reservations_p: "comment_node_lihtc_allocations_reservations_p"
comment_node_lihtc_allocations_reservations_s: "comment_node_lihtc_allocations_reservations_s"
comment_node_real_estate_professional: "comment_node_real_estate_professional"
comment_node_irs_housing_credit_percentage: "comment_node_irs_housing_credit_percentage"
comment_node_rental_housing_document: "comment_node_rental_housing_document"
comment_node_income_limit_information: "comment_node_income_limit_information"
comment_node_purchase_price_limit_information: "comment_node_purchase_price_limit_information"
comment_node_board_of_commissioners_meetings: "comment_node_board_of_commissioners_meetings"
comment_node_bond_disclosure_types: "comment_node_bond_disclosure_types"
comment_node_committee_meeting_document: "comment_node_committee_meeting_document"
comment_node_homeownership_landing_page: "comment_node_homeownership_landing_page"
comment_node_questions_and_answers: "comment_node_questions_and_answers"
comment_node_homeownership_document: "comment_node_homeownership_document"
comment_node_homeownership_program: "comment_node_homeownership_program"
comment_node_homeownership_product: "comment_node_homeownership_product"
comment_node_mcc_program_public_notice: "comment_node_mcc_program_public_notice"

Here’s the issue where work proceeds toward a proper fix:

How to fix “non-existent config entity name returned by FieldStorageConfigInterface::getBundles()” [#2916266] | Drupal.org

Here’s what i did, in a drush sqlc, but only run this query if you have deleted every comment field and uninstalled the comment module:

DELETE FROM key_value WHERE collection="entity.definitions.bundle_field_map" AND name="comment";

As an aside, the first thing to trigger the error unsurprisingly was layout builder, and disabling that is a whole other issue: Layout Builder cannot be uninstalled while overrides exist; no easy way to revert all overrides [#2980299] | Drupal.org