Skip to content

Fail deployment on hardcoded references to the current namespace#2253

Merged
shangyian merged 3 commits into
DataJunction:mainfrom
shangyian:validate-dim-reachability
Jun 13, 2026
Merged

Fail deployment on hardcoded references to the current namespace#2253
shangyian merged 3 commits into
DataJunction:mainfrom
shangyian:validate-dim-reachability

Conversation

@shangyian

Copy link
Copy Markdown
Collaborator

Summary

When working in a branch namespace (<namespace>.<branch>.<...>), it's possible to write a node query that hardcodes a reference to the current branch namespace instead of using ${prefix}. For example, a metric deployed to myteam.feature_branch that references myteam.feature_branch.transforms.revenue_fact directly.

The change will validate and deploy cleanly while the branch exists, but breaks after merge. Once the branch is merged to main and the temporary branch namespace is cleaned up, the hardcoded reference becomes a dangling pointer to a namespace that no longer exists. The failure only surfaces later, at SQL-request time, with a confusing "cannot find join path" or missing-node error far removed from the actual cause.

Thus, during deployment validation, we should flag any node whose query references a dependency starting with the deployment namespace prefix. Such a reference should always go through ${prefix} so it survives branch merges.

To do this, we added _check_hardcoded_namespace_ref to NodeSpecBulkValidator, where for each dependency in the node's already-computed dependency list, we check whether it starts with deployment_namespace. If so, we mark the node INVALID with an INVALID_NAMESPACE error directing the user to use ${prefix}. Other nodes in the push are unaffected.

This change makes no additional DB queries, so there should be perf degradation for deploying.

Test Plan

Added four unit tests covering: hardcoded self-reference produces the error, cross-namespace references are allowed, the check is skipped when no deployment namespace is set (REST API path), and clean queries produce no error.

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 3f465fd
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6a2d6950dfc3830008e16af9

@shangyian shangyian force-pushed the validate-dim-reachability branch from f020992 to c0ef641 Compare June 12, 2026 04:54
@shangyian shangyian marked this pull request as ready for review June 13, 2026 15:31
@shangyian shangyian merged commit 56e90fa into DataJunction:main Jun 13, 2026
21 checks passed
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