List taxonomies by post id

Have you set WP_DEBUG and WP_DEBUG_LOG to true in your wp-config.php?

Doing so makes debugging a lot easier as you’ll get an error_log in your wp-content directory, which will tell you what is it it your code that is causing the error.

If I had to make a guess, I’d say it’s the $post->id that might be causing the problem as $post might be undefined. Unless you have defined it in your code earlier, but just left it out from the code you’ve shared. You could try replacing it with get_the_ID() as it defaults to the current global post like has_term does when no post or post_id is provided.

But check your error_log to be sure.