Menu disappears with custom post type link

pre_get_posts filters will be applied to all queries on a page- the main query, menus, and additional WP_Query instances.

To target only the main query, use is_main_query():

function my_pre_get_posts( $query ) {

    // bail early if is in admin
    // or if query is not main query
    if( is_admin() || !$query->is_main_query() ) {
        return;
    }

    // get meta query
    $meta_query = $query->get('meta_query');

    if(!empty($_GET['contract']))
    {
        $contract = explode(',', $_GET['contract']);
        $meta_query[] = array(
        'key' => 'contract',
        'value' => $_GET['contract'],
        'compare' => 'IN',
        );
    }

    $query->set('meta_query', $meta_query);

    return;
}

error code: 523