fix: raise correct deprecation when config key is top-level in generic test (#12572)#12618
Open
kalluripradeep wants to merge 1 commit intodbt-labs:mainfrom
Open
Conversation
…vel of generic test Fixes dbt-labs#12572
2 tasks
ash2shukla
requested changes
Mar 18, 2026
Contributor
ash2shukla
left a comment
There was a problem hiding this comment.
Thanks for this work !
Please address following comments and we can merge it !
| config_keys_at_root = [ | ||
| k for k in test_args.keys() | ||
| if k not in ("config", "column_name", "description", "name") | ||
| and k in TestBuilder.CONFIG_ARGS |
Contributor
There was a problem hiding this comment.
I think the checks against CONFIG_ARGS here is redundant as CONFIG_ARGS and ("config", "column_name", "description", "name") are mutually exclusive.
Probably reword this block like following -
for k in test_args.keys():
if k in TestBuilder.CONFIG_ARGS:
deprecations.warn(
"property-moved-to-config-deprecation",
key=k,
file=file_path,
key_path=f"data_tests.{test_name}.{k}",
)
top_level_keys = ("config", "column_name", "description", "name", *TestBuilder.CONFIG_ARGS)
if not arguments and any(k not in top_level_keys for k in test_args.keys()):
resource = (
f"'{resource_name}' in package '{package_name}'"
if package_name
else f"'{resource_name}'"
)
deprecations.warn(
"missing-arguments-property-in-generic-test-deprecation",
test_name=f"`{test_name}` defined on {resource} ({file_path})",
)| PropertyMovedToConfigDeprecation, not MissingArgumentsPropertyInGenericTestDeprecation.""" | ||
|
|
||
| @pytest.fixture(scope="class") | ||
| def dbt_profile_target(self): |
Contributor
There was a problem hiding this comment.
We dont need to patch profile target for this test.
| ["parse", "--no-partial-parse", "--show-all-deprecations"], | ||
| callbacks=[moved_catcher.catch, missing_catcher.catch], | ||
| ) | ||
| assert len(moved_catcher.caught_events) >= 1, ( |
Contributor
There was a problem hiding this comment.
There should be exactly one event in this case, check for equality please == 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #12572
Parent: #12394
When a user defines a config property like
whereat the top level of a generic test:dbt was raising
MissingArgumentsPropertyInGenericTestDeprecation, which misleads the developer into movingwhereunderarguments:— which is wrong. The correct fix is to move it underconfig:.Root Cause
In
TestBuilder.extract_test_args(), the check for missingargumentsproperty did not distinguish between actual test arguments and known config properties (CONFIG_ARGSlikewhere,severity,tags, etc.). Any top-level key that wasn'tconfig,column_name,description, ornametriggered the wrong deprecation.Fix
Exclude
CONFIG_ARGSfrom the missing-arguments check inextract_test_args()so that known config properties don't triggerMissingArgumentsPropertyInGenericTestDeprecationEmit
PropertyMovedToConfigDeprecationfor eachCONFIG_ARGSkey found at the root level of the test definition, guiding the developer to move it underconfig:Test
Added
TestMissingArgsVsPropertyMovedToConfigintests/functional/deprecations/test_deprecations.pywhich verifies:PropertyMovedToConfigDeprecationfires forwhereat top levelMissingArgumentsPropertyInGenericTestDeprecationdoes NOT firecc @dbeatty10