Skip to content

[Bug] Clarify error message with intended flow for deleting contracted models #11667

@jenna-jordan

Description

@jenna-jordan

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When a user tries to delete a contracted (possibly versioned) model, they get an error message that looks like:

While comparing to previous project state, dbt detected a breaking change to an enforced contract.
- Contracted model 'model.project_name.mart_model.v1' was deleted or renamed.
Consider making an additive (non-breaking) change instead, if possible.

While it is good for model governance to have teeth and prevent a breaking change, what if the user really does need to remove the model? This error message seems to imply that they simply can't.

Expected Behavior

The correct flow is explained in this issue: #7433
Here is another related issue: #10116

If a user wants to delete a contracted model, they should first set a deprecation_date. Then the current date must be later than that deprecation_date. After this, the model can be deleted.

The error message should be revised to point users towards this intended flow. For example:

While comparing to previous project state, dbt detected a breaking change to an enforced contract.
- Contracted model 'model.project_name.mart_model.v1' was deleted or renamed.
Only a model with a deprecation date that is past can be removed. <If there is no deprecation_date> Please set a deprecation_date for <model>. <OR if a deprecation date is set> This model should not be removed until <date>, the current deprecation_date.

There are also complications related to model versions that need to be resolved, like: #11176

The intended behavior around deprecating a model version vs deprecating a root model should be clarified, and this should also be included in the error message. For example, if someone has set a deprecation date only on the latest version, but not the root model, they may need to be prompted to add that deprecation_date to the root model instead if they are trying to delete a model as a whole (vs just a single version).

Steps To Reproduce

The dbt project should be on version 1.8+. There should be a model with an enforced contract. In order to merge changes, the PR will need to pass a standard CI check. Attempt to delete the contracted model, and the error should show up in the CI job.

Relevant log output

Environment

dbt Cloud versionless

Which database adapter are you using with dbt?

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions