diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
index 4a4ab59..b6eaf59 100644
--- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
@@ -223,6 +223,9 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte
       // @todo Remove this once https://www.drupal.org/node/2359901 lands.
       if (!empty($main_content)) {
         $this->renderer->executeInRenderContext(new RenderContext(), function() use (&$main_content) {
+          if (!isset($main_content['#cache'])) {
+            throw new \LogicException('Must have cacheability metadata.');
+          }
           if (isset($main_content['#cache']['keys'])) {
             // Retain #title, otherwise, dynamically generated titles would be
             // missing for controllers whose entire returned render array is
