diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index ad1c8e96f3656281a6315acf08e904d12477edff..bb59c5e0bfe29fc1960ea2d84dcbed94e30c293a 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -586,9 +586,11 @@ function template_preprocess_node(&$variables) {
         // 'compact' view mode on the User entity. Note that the 'compact'
         // view mode might not be configured, so remember to always check the
         // theme setting first.
-        $variables['author_picture'] = \Drupal::entityTypeManager()
-          ->getViewBuilder('user')
-          ->view($node->getOwner(), 'compact');
+        if ($node_owner = $node->getOwner()) {
+          $variables['author_picture'] = \Drupal::entityTypeManager()
+            ->getViewBuilder('user')
+            ->view($node_owner, 'compact');
+        }
       }
     }
   }