Skip to content

+pre_hook is relocated to +meta instead of +pre-hook (silent behavior break) #373

Description

@holdthez

Summary

When running uvx dbt-autofix against a dbt_project.yml that uses +pre_hook: at a model-group level, the tool moves the key into +meta: rather than renaming it to the canonical +pre-hook: hyphen form that dbt-core + Fusion expect. The result silently disables execution of the hook — +meta is free-form metadata with no runtime effect.

Version: dbt-autofix==0.20.3 (reproduced on 0.19.x also).

Reproduction

Minimal dbt_project.yml input:

models:
  myproject:
    marts:
      +materialized: table
      +pre_hook: "SET LOCAL statement_timeout = '900s'"

Run: uvx dbt-autofix

Actual output:

models:
  myproject:
    marts:
      +materialized: table
      +meta:
        pre_hook: "SET LOCAL statement_timeout = '900s'"

Expected output (canonical hyphen form per dbt 1.10+ schema, Fusion-compatible):

models:
  myproject:
    marts:
      +materialized: table
      +pre-hook: "SET LOCAL statement_timeout = '900s'"

Impact

+meta is dbt's free-form metadata bag with no execution semantics. Whatever SQL was previously wrapped in pre_hook now silently stops firing on every run, which is especially dangerous when the hook was load-bearing (e.g., a statement-level timeout for large-table materializations). Users discover the regression only when a downstream mart starts timing out in production or an audit catches the behavior gap.

Context

We hit this migrating a dbt-core 1.11.2 project to the 1.10-compatible schema to prepare for Fusion. Workaround we documented in our repo's memory: revert the dbt_project.yml change after autofix, then rename +pre_hook+pre-hook manually. All other autofix transformations (arguments: nesting for generic tests, source freshness moves, etc.) applied cleanly.

Suggested fix

The PropertyMovedToConfigDeprecation pass appears to be catching pre_hook as a plain property and routing it under +meta instead of recognizing it as a hook key that needs the hyphen rename via ConfigPreHookDeprecation (or equivalent). The hook-specific rename should run before (or exclude from) the generic move-to-meta pass.

Happy to open a PR if a test fixture + the pass ordering fix is the right shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions