I am working on an AWS CloudFormation stack to host Drupal and running into a reproducible issue with the Drupal installer. The hosting setup uses Ubuntu 18.04, PHP7.4, and MySQL Aurora 5.7. I am connecting to MySQL via SSH using the AWS CA file. Once the stack completes setting up, the user is presented with the Drupal 9 installation page. The settings.php has been already written with preconfigured values for the database settings, hash salt, config_sync_directory and some overridden module settings. After clicking to continue with the installation, Drupal installs progressively and the user is presented with the configuration form. Once this form is submitted, a WSOD appears with the text "The website encountered an unexpected error. Please try again later.The website encountered an unexpected error. Please try again later."
Looking at errors logs, I see the following error (formatted in JSON):
{"time":"2020-06-16 10:17:03.257270", "function":"[php7:notice]", "process":"[pid8309]", "message":"TypeError: Argument 1 passed to Drupal\\Core\\Entity\\Sql\\DefaultTableMapping::Drupal\\Core\\Entity\\Sql\\{closure}() must implement interface Drupal\\Core\\Field\\FieldStorageDefinitionInterface, instance of __PHP_Incomplete_Class given in /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php on line 174 #0 [internal function]: Drupal\\Core\\Entity\\Sql\\DefaultTableMapping::Drupal\\Core\\Entity\\Sql\\{closure}()\n#1 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php(176): array_filter()\n#2 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(381): Drupal\\Core\\Entity\\Sql\\DefaultTableMapping::create()\n#3 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(356): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->getCustomTableMapping()\n#4 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(203): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->getTableMapping()\n#5 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(188): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->initTableLayout()\n#6 /var/www/app/drupal/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(156): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->__construct()\n#7 /var/www/app/drupal/core/lib/Drupal/Core/Entity/EntityTypeManager.php(285): Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage::createInstance()\n#8 /var/www/app/drupal/core/lib/Drupal/Core/Entity/EntityTypeManager.php(274): Drupal\\Core\\Entity\\EntityTypeManager->createHandlerInstance()\n#9/var/www/app/drupal/core/lib/Drupal/Core/Entity/EntityTypeManager.php(208): Drupal\\Core\\Entity\\EntityTypeManager->getHandler()\n#10 /var/www/app/drupal/core/modules/user/src/EventSubscriber/UserRequestSubscriber.php(54): Drupal\\Core\\Entity\\EntityTypeManager->getStorage()\n#11 /var/www/app/drupal/vendor/symfony/event-dispatcher/LegacyEventDispatcherProxy.php(78): Drupal\\user\\EventSubscriber\\UserRequestSubscriber->onKernelTerminate()\n#12 /var/www/app/drupal/vendor/symfony/http-kernel/HttpKernel.php(100): Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy->dispatch()\n#13 /var/www/app/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(32): Symfony\\Component\\HttpKernel\\HttpKernel->terminate()\n#14 /var/www/app/drupal/core/lib/Drupal/Core/DrupalKernel.php(683): Stack\\StackedHttpKernel->terminate()\n#15 /var/www/app/drupal/index.php(22): Drupal\\Core\\DrupalKernel->terminate()\n#16 {main}"}
Subsequent requests to the index page give the same WSOD and the following error:
{"time":"2020-06-16 10:17:19.290540", "function":"[php7:notice]", "process":"[pid8330]", "message":"Uncaught PHP Exception InvalidArgumentException: "Class "Drupal\\views\\Routing\\ViewPageController" does not exist." at /var/www/app/drupal/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php line 24"}
Logging into the server via SSH and clearing the cache fixes the issue immediately and the site resumes as normal.
From my own research, I thought the issue was originally related to
https://www.drupal.org/project/drupal/issues/3103529 β
and some initial attempts to fix it by unsetting the Drupal container before the installation's final step to redirect to the homepage seemed to work, but only fixed ancillary problems caused by this. The code in Drupal\Core\Entity\Sql\DefaultTableMapping::create() seems very meta to me and I'm unable to follow without much deeper knowledge of the core system so far.
When I tried to reproduce this error locally on my own Ubuntu 18.04, PHP7.4 with local MySQL, I couldn't.