Skip to content

Fix: skip self-owned nodes to prevent stale re-injection in circular loom topologies - #181

Open
tmirko wants to merge 1 commit into
adrienneyager:mainfrom
tmirko:main
Open

tmirko wants to merge 1 commit into
adrienneyager:mainfrom
tmirko:main

Conversation

@tmirko

@tmirko tmirko commented Jun 25, 2026

Copy link
Copy Markdown

Hi @nicholasyager, I've encountered another issue related to circular topologies in loom for which I'm proposing a fix.

Problem

In circular loom topologies (e.g. project A references project B, and project B also
references project A), the upstream manifest contains a snapshot of the root project's
own nodes captured at publication time. When the root project compiles, dbt-loom
injects those stale nodes back into the graph.

If any of those nodes reference models that have since been disabled or deleted locally,
dbt raises:

Compilation Error
'model.project_a.some_model' depends on 'model.project_a.other_model'
which is not in the graph!

The existing merge_loom_nodes deduplication logic (introduced in #164) does not
cover this case because the offending node's package_name matches the root project,
not a third package.

Root Cause

merge_loom_nodes (and therefore initialize()) had no guard preventing a project
from injecting nodes that belong to its own package. A transitive copy arriving via
an upstream manifest is by definition stale; the local project is always authoritative
for its own nodes.

Fix

Extended merge_loom_nodes with an optional root_project_name parameter. Any node
whose package_name == root_project_name is dropped before the authoritative-merge
step. dbtLoom.initialize() passes self.project_name for this parameter, so the
guard is applied automatically for every manifest that is loaded.

No changes to the public API — root_project_name defaults to None, preserving
existing behaviour when the parameter is not supplied.

Tests Added

tests/test_node_deduplication.py:

  • test_root_project_nodes_are_not_reinjected — a stale self-owned node arriving via
    an upstream manifest is not present in the merged result when root_project_name is
    set.
  • test_non_root_nodes_still_injected_when_root_project_name_set — setting
    root_project_name does not prevent nodes from other packages from being injected.

All six tests in the file pass.

This branch has not been deployed

No deployments
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.

1 participant