Skip to content

Fix node resolution on dbt Fusion (missing version kwarg resolves to '' instead of None) - #226

Open
allllllllez wants to merge 1 commit into
EqualExperts:masterfrom
allllllllez:fix/fusion-kwargs-default-empty-string
Open

Fix node resolution on dbt Fusion (missing version kwarg resolves to '' instead of None)#226
allllllllez wants to merge 1 commit into
EqualExperts:masterfrom
allllllllez:fix/fusion-kwargs-default-empty-string

Conversation

@allllllllez

Copy link
Copy Markdown

Fix node resolution on dbt Fusion (missing version kwarg resolves to '' instead of None)

Fixes #225

Problem

Every dbt_unit_testing.test() fails on dbt Fusion with Node ... not found.. The graph
lookup in macros/utils.sql (model_node) is not at fault — graph is fully populated and
the target node matches correctly. The actual cause is that node.version ends up as ''
instead of None when no version/v kwarg is passed. has_value() treats '' as "a
version was requested", filters by version == '', and finds nothing since real unversioned
models have version == None.

Three call sites share the same fragile pattern, which relies on dbt Core's Python Jinja2
Undefined semantics for a missing kwargs key — a dependency Fusion's Jinja implementation
doesn't honor the same way:

{% set node_version = kwargs["version"] | default(kwargs["v"]) | default(none) %}

Change

Replace the bracket-index + default() chain with kwargs.get("x", kwargs.get("y", none)) in:

  • macros/overrides.sql (ref() override — hit by every single test via ref_tested_model())
  • macros/tests.sql (dbt_unit_testing.test())
  • macros/mock_builders.sql (mock_ref())

No change to macros/utils.sql — the graph lookup itself was already correct.

Verification

Using this repo's integration-tests/ suite (31 dbt_unit_testing.test() cases), on branch
fix/fusion-kwargs-default-empty-string:

Engine Before After
dbt Fusion 2.0.0-preview.205 (Postgres, experimental adapter) 31/31 tests fail to compile (Node ..._v not found) 29/31 succeed at compile. Remaining 2 fail with [DbDriverFailed] HTTP error: io: No route to host — an unrelated connectivity limitation of Fusion's experimental postgres adapter, not a render/Jinja error
dbt Core 1.7.11 (existing test matrix, Postgres) 31/31 build + 31/31 test pass Same — no regression
dbt Core 1.12.3 (latest available via pip install dbt-postgres==1.11.0, Postgres) n/a Full run-integration-tests.sh passes, no regression

Full reproduction/verification commands are in #225.

… dbt Fusion

kwargs["version"] | default(kwargs["v"]) | default(none) relies on Jinja2's
Undefined semantics for a missing kwarg key. On dbt Fusion, indexing a missing
kwargs key does not produce Undefined, so it survives as '' and default(none)
never fires. has_value() then treats '' as "a version was given", filters the
graph node by version=='', and finds nothing since real unversioned models have
version=None. Affects overrides.sql's ref() override (hit by every test via
ref_tested_model), tests.sql's test(), and mock_builders.sql's mock_ref().

Fixes EqualExperts#225
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.

Bug: node resolution fails on dbt Fusion because a missing version kwarg resolves to '' instead of None

1 participant