Skip to content

feat: dbt adapter allow invalid ref for tests#5207

Merged
eakmanrq merged 2 commits intomainfrom
eakmanrq/dbt_allow_invalid_ref_tests
Aug 22, 2025
Merged

feat: dbt adapter allow invalid ref for tests#5207
eakmanrq merged 2 commits intomainfrom
eakmanrq/dbt_allow_invalid_ref_tests

Conversation

@eakmanrq
Copy link
Collaborator

Dbt ignores with a warning tests that have refs to models that don't exist. This mimics that behavior.

dbt function that explicitly does not fail if test: https://github.com/dbt-labs/dbt-core/blob/0836095a572532fc22b1c0981346eebe56f7d1fb/core/dbt/parser/manifest.py#L1324-L1332

I noticed in testing that constraints that make invalid refs also do not affect execution so I included that in the test although I didn't have to make any code changes at this time to support it.

models[ref] = t.cast(ModelConfig, model)
else:
raise ConfigError(f"Model '{ref}' was not found.")
exception = MissingModelError(f"Model '{ref}' was not found.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you didnt follow the existing pattern with ApiError, NodeAuditsErrors etc and make model_name part of the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't think about of it for some reason and yeah that is a better approach. Updating.

@eakmanrq eakmanrq force-pushed the eakmanrq/dbt_allow_invalid_ref_tests branch from 4fd2ae1 to 1107e93 Compare August 22, 2025 14:46
@eakmanrq eakmanrq force-pushed the eakmanrq/dbt_allow_invalid_ref_tests branch from 1107e93 to 53c1ad3 Compare August 22, 2025 15:12
@eakmanrq eakmanrq merged commit d3eae73 into main Aug 22, 2025
28 checks passed
@eakmanrq eakmanrq deleted the eakmanrq/dbt_allow_invalid_ref_tests branch August 22, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants