diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index eb3050e82ff91c6f385dd18e152c61d6101d4312..6ccdf406f2990884b7af1b90eea5987fef6e4aaf 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -553,9 +553,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');
+        }
       }
     }
   }