Custom Post Type, 404 error

I solved by eliminating the following portion of code: I don’t remember why I had to code it, it apparently solved an issue, even if I don’t remember what issue.

The portion is the following:

add_action('pre_get_posts', function ($query) {
                if (!is_admin() && $query->is_main_query() && empty($query->query_vars['suppress_filters'])) {

        if (is_archive()) {

            if (is_category()) {
                $query->set('post_type', ['post', 'docs']);
            } else {
                if (!is_tag()) {
                    $query->set('post_type', 'docs');
                } else {
                    $query->set('post_type', 'post');
                }
            }
        }
    }
});

Maybe a newer version of WordPress had compatibility issues with this code.