Index: src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php	(revision 40556)
+++ src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php	(revision )
@@ -474,7 +474,7 @@
 		$data     = $this->prepare_item_for_response( $post, $request );
 		$response = rest_ensure_response( $data );
 
-		if ( is_post_type_viewable( get_post_type_object( $post->post_type ) ) ) {
+		if ( ! is_wp_error( $response ) && is_post_type_viewable( get_post_type_object( $post->post_type ) ) ) {
 			$response->link_header( 'alternate',  get_permalink( $post->ID ), array( 'type' => 'text/html' ) );
 		}
 
