So if the $id is not correct, the $post->ID will throw a Notice: Trying to get property of non-object in file.php on line n
I think we can use a simple "!$post" or "is_a( $post, 'WP_Post' ) )" here.
Thanks for reading