block definition inside control flow

I am getting the following error:

Got a block definition inside control flow at 240:0. All dbt block definitions must be at the top level

This is a fairly simple model. It’s three levels of views. dbt run was working yesterday with 0 errors. Today I am getting this error but idk where it’s coming from.

 {{
    config (
        alias = 'trova_profiles',
        materialized='view',
        tags=['trova_profiles']
    )
}}

select distinct
    {{
        dbt_utils.generate_surrogate_key(
            ['c.driver_number', 'a.user_id', 'c.federal_terminal']
        )
    }} as trova_profiles_pk,
    c.driver_number as driver_number,
    a.user_id as slack_user_id,
    c.status as staus,
    c.driver as driver,
    b.rm_name as driver_rm,
    c.terminal as terminal,
    c.federal_terminal as federal_terminal,
    c.city as city,
    c.state as state,
    c.days_till_expiration as must_visit_in,
    c.day_of_last_visit as day_of_last_visit,
    c.expiration_type as expiration_cycle
from {{ ref('stg_slack_user') }} as a
join {{ ref('int_gemini_salesforce_census_join_agg') }} as b
    on lower(a.user_email) = lower(b.email)
left join {{ ref('int_terminal_cards') }} as c
    on to_char(b.employee_id) = to_char(c.driver_number)
where
    ifnull(to_date(c.day_of_last_visit) = to_date(c.last_visited_actual), true) = true
    and driver_number is not null