Skip to content

fix: rediscover built-in generic test macros and reflect them in target/manifest.json under --use-v2-parser - #15925

Merged
tauhid621 merged 3 commits into
1.latestfrom
fix/fusion-generic-test-macro-rediscovery
Aug 18, 2026
Merged

fix: rediscover built-in generic test macros and reflect them in target/manifest.json under --use-v2-parser#15925
tauhid621 merged 3 commits into
1.latestfrom
fix/fusion-generic-test-macro-rediscovery

Conversation

@aiguofer

@aiguofer aiguofer commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two related bugs in the --use-v2-parser (Fusion) manifest-loading path, both surfacing as the built-in generic tests (not_null, unique, accepted_values, relationships) failing to compile.

Fixes #15914

  • rediscover_adapter_macros() (added in fix: re-parse adapter macros from installed package after loading Fusion manifest #15529) evicts internal-package macros embedded by Fusion, then re-parses replacements from the installed adapter/dbt-core packages using only MacroParser over macro_paths. The four built-in generic tests are {% test %} blocks under tests/generic/, parsed by a different class (GenericTestParser) over a different path list (generic_test_paths). They were evicted but never restored, leaving them permanently missing from the compile-time macro namespace and producing 'test_not_null' is undefined. Fixed by adding an equivalent reparse pass with GenericTestParser over generic_test_paths.
  • target/manifest.json was written by copying Fusion's raw handoff file before rediscover_adapter_macros ran, so the on-disk artifact still reflected Fusion's bundled (pre-correction) macros rather than what was actually used to compile — a discrepancy an external consumer of manifest.json would otherwise never catch. Fixed by writing manifest.json from the corrected in-memory manifest after rediscovery completes; semantic_manifest.json is unaffected by macro rediscovery and is still copied as-is.

Added TestRediscoverAdapterMacros::test_restores_evicted_generic_test_macros and updated TestParseWithFusion::test_write_json_writes_corrected_manifest_to_target_dir to cover both fixes. Manually reproduced end-to-end with a minimal duckdb project against both dbt-core-experimental-parser 2.0.0a1 and 2.0.0b1: the built-in generic tests went from ERROR: 'test_not_null' is undefined to PASS, and the manifest.json fix was confirmed by injecting a marker into the installed adapter's tests/generic/builtin.sql and observing it now appears in the written target/manifest.json post-rediscovery.

…et/manifest.json under --use-v2-parser

rediscover_adapter_macros() evicted internal-package macros then re-parsed
replacements using only MacroParser over macro_paths. The four built-in
generic tests (test_not_null, test_unique, test_accepted_values,
test_relationships) are {% test %} blocks under tests/generic/, parsed by
GenericTestParser over generic_test_paths instead, so they were evicted and
never restored, leaving them undefined at test-compile time.

Also, target/manifest.json was written by copying Fusion's raw handoff file
before rediscovery ran, so the on-disk artifact still reflected Fusion's
bundled macros rather than the corrected ones actually used to compile.
manifest.json is now written from the corrected in-memory manifest after
rediscovery completes; semantic_manifest.json is unaffected and still copied
as-is.
Copilot AI lite review requested due to automatic review settings August 12, 2026 19:38
@aiguofer
aiguofer requested a review from a team as a code owner August 12, 2026 19:38
@cla-bot cla-bot Bot added the cla:yes label Aug 12, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two Fusion (--use-v2-parser) manifest-loading issues in dbt-core: (1) built-in generic test macros were being evicted during adapter macro rediscovery and not restored, and (2) target/manifest.json could be written from Fusion’s pre-rediscovery handoff artifact rather than the corrected in-memory Manifest, creating an on-disk/compile-time mismatch.

Changes:

  • Extend rediscover_adapter_macros() to also re-parse built-in generic tests via GenericTestParser over generic_test_paths.
  • Write target/manifest.json from the corrected in-memory Manifest after rediscovery (while continuing to copy semantic_manifest.json as-is).
  • Add/update unit tests to cover restored generic test macros and corrected manifest.json writing behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
core/dbt/parser/fusion.py Writes manifest.json from the corrected in-memory manifest and re-parses generic tests during macro rediscovery.
tests/unit/parser/test_fusion.py Updates/extends unit tests to validate corrected manifest writing and generic test macro restoration.
.changes/unreleased/Fixes-20260812-133414.yaml Changelog entry for corrected target/manifest.json writing behavior.
.changes/unreleased/Fixes-20260812-130820.yaml Changelog entry for restoring built-in generic test macros after Fusion manifest load.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .changes/unreleased/Fixes-20260812-130820.yaml Outdated
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.51%. Comparing base (4a7a7c7) to head (a7e7553).

Additional details and impacted files
@@             Coverage Diff              @@
##           1.latest   #15925      +/-   ##
============================================
- Coverage     91.52%   91.51%   -0.01%     
============================================
  Files           222      222              
  Lines         28259    28268       +9     
============================================
+ Hits          25864    25870       +6     
- Misses         2395     2398       +3     
Flag Coverage Δ
integration 87.80% <100.00%> (-0.02%) ⬇️
unit 66.95% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 66.95% <100.00%> (+0.01%) ⬆️
Integration Tests 87.80% <100.00%> (-0.02%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The Fixes-20260812-130820.yaml changelog entry had leftover XML-like
tags appended after the valid YAML content, breaking the check-yaml
pre-commit hook in CI.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Failed
Enforce advisory code health rules (1 file with Complex Method)

Our agent can fix these. Install it.

Gates Passed
3 Quality Gates Passed

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
fusion.py 1 advisory rule 8.10 → 8.04 Suppress

See analysis details in CodeScene

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Comment thread core/dbt/parser/fusion.py
@aiguofer aiguofer self-assigned this Aug 12, 2026
Comment thread core/dbt/parser/fusion.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants