Skip to content

fix: re-run macro argument validation after partial parse reuse (#12574)#12617

Open
kalluripradeep wants to merge 2 commits intodbt-labs:mainfrom
kalluripradeep:fix-macro-arg-validation-partial-parse
Open

fix: re-run macro argument validation after partial parse reuse (#12574)#12617
kalluripradeep wants to merge 2 commits intodbt-labs:mainfrom
kalluripradeep:fix-macro-arg-validation-partial-parse

Conversation

@kalluripradeep
Copy link
Contributor

Problem

Fixes #12574

When dbt parse is run a second time without any file changes, partial parsing determines nothing has changed (skip_parsing=True) and reuses the saved manifest as-is. In this path, MacroPatchParser.parse_patch is never called, so _check_patch_arguments is never triggered — causing macro argument mismatch warnings to silently disappear on all subsequent runs.

Root Cause

_check_patch_arguments was only reachable through parse_patch, which is skipped entirely during skip_parsing partial parse reuse. There was no mechanism to re-run validation against the cached manifest.

Fix

  1. Extracted validation logic from MacroPatchParser._check_patch_arguments into a standalone module-level function validate_macro_arguments() in schemas.py, so it can be called from multiple call sites.

  2. Added ManifestLoader._revalidate_macro_arguments() in manifest.py, which runs after self.manifest = self.saved_manifest when validate_macro_args is enabled. It re-extracts Jinja arguments directly from macro_sql and compares them against the YAML arguments stored in the schema file's dict_from_yaml, mirroring what MacroParser and MacroPatchParser do during a full parse.

Test

Added TestMacroArgValidationAfterPartialParse to tests/functional/macros/test_macro_annotations.py which:

  • Runs dbt parse once (full parse) and asserts the warning fires
  • Runs dbt parse again with no changes (partial parse, skip_parsing=True) and asserts the warning still fires

This is the exact repro case from the issue.

@kalluripradeep kalluripradeep requested a review from a team as a code owner March 8, 2026 15:40
@cla-bot cla-bot bot added the cla:yes label Mar 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@github-actions github-actions bot added the community This PR is from a community member label Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes community This PR is from a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Incorrect macro argument validation

1 participant