Skip to content

fix: use tuple membership check instead of substring match in selection_arg#12562

Open
kalluripradeep wants to merge 2 commits intodbt-labs:mainfrom
kalluripradeep:fix-show-selector-substring-bug
Open

fix: use tuple membership check instead of substring match in selection_arg#12562
kalluripradeep wants to merge 2 commits intodbt-labs:mainfrom
kalluripradeep:fix-show-selector-substring-bug

Conversation

@kalluripradeep
Copy link
Contributor

Fixes #12539

What changed

Fixed a one-character bug in core/dbt/task/show.py and
core/dbt/task/compile.py where self.selection_arg[0] was used
instead of self.selection_arg in the result filtering loop.

Why

self.selection_arg is a tuple like ('my_model_show',).

Using result.node.name in self.selection_arg[0] does a substring
check on a string
, not a membership check on the tuple:

# Buggy behaviour:
'show' in 'my_model_show'   # True  ← wrong, show is a substring
'show' in ('my_model_show',) # False ← correct, show is not in the tuple

So any model whose name contained a common substring like show,
model, or my would incorrectly match other nodes during result
filtering, causing inconsistent behaviour depending on the model name.

How I fixed it

Removed the [0] index in both files so the check becomes a proper
tuple membership check:

# Before:
if result.node.name in self.selection_arg[0]:

# After:
if result.node.name in self.selection_arg:

Files changed

  • core/dbt/task/show.py
  • core/dbt/task/compile.py

@kalluripradeep kalluripradeep requested a review from a team as a code owner February 28, 2026 15:33
@cla-bot cla-bot bot added the cla:yes label Feb 28, 2026
@github-actions github-actions bot added the community This PR is from a community member label Feb 28, 2026
@graciegoheen graciegoheen added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Feb 28, 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 ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] dbt test --select skips YAML data tests for models with _show in name

2 participants