Getting the post ID in parse_query

Thank you for your responses. After a bit of testing, I hooked onto WP (https://developer.wordpress.org/reference/hooks/wp/) which occurs near the end of the WordPress loading sequence, and it is now working:

function wf_lang_query_check() {
    
    global $wp_query, $post;
    
    $lang =  wf_get_lang();
        
    if ( ( !is_admin() && $wp_query->is_main_query() ) && ( $lang && ( !in_array(  $lang, wf_valid_lang() ) || !wf_check_if_has_translations($post->ID,  $lang ) ) ) ):
    
       $wp_query->set_404();
       status_header( 404 );
        
    endif;
    
}
add_action( 'wp', 'wf_lang_query_check' );