#16554·dbt-core

[v2 Bug] dbt check: sources cannot be selected, so checks that report sources are skipped with --select and state:modified

Author: b-perCreated Oct 1, 2026Updated Oct 1, 2026
Labelstype:bugengine:v2v2checks

Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

  • I believe this is a new bug in dbt v2.x
  • I have searched the existing issues and could not find a duplicate (closest: #16553, #16503, #15845 — none covers selecting sources in dbt check)

Current Behavior

dbt check cannot select sources. Any selector that resolves only to sources (source:*, source:raw.unused_table, resource_type:source, a source unique_id) is reported as "does not match any enabled nodes", and state:modified does not see a changed source either. The command then exits 0 without evaluating anything.

The same selectors work in dbt ls, so this is specific to how dbt check scopes the rows of a check, not to node selection in general.

Checks that report sources (a source unique_id in their unique_id column) are therefore never evaluated once a selector is set, for example in a CI job that runs dbt check --select state:modified --state <path>. A pull request that only changes a source can pass without any source check running.

Expected Behavior

A selector that selects sources scopes the rows of checks that report sources, the same way selecting a model scopes the rows of checks that report models. dbt check --select source:raw.unused_table reports that source if the check flags it, and dbt check --select state:modified covers changed sources.

Use case: the dbt-project-evaluator native-check port has 7 checks whose rows are sources (unused sources, sources without freshness, undocumented source tables and sources, duplicate sources, source directories, source fanout). None of them can be used with --select.

Steps To Reproduce

dbt_project.yml

yaml
name: repro_source_selection
version: '1.0.0'
profile: repro_source_selection
model-paths: ["models"]
check-paths: ["checks"]
info_schema:
  version: 1

profiles.yml

yaml
repro_source_selection:
  target: dev
  outputs:
    dev:
      type: duckdb
      path: dev.duckdb
      threads: 1

models/sources.yml

yaml
sources:
  - name: raw
    description: Raw data.
    tables:
      - name: orders
      - name: unused_table

models/stg_orders.sql

sql
select * from {{ source('raw', 'orders') }}

checks/unused_source.sql

sql
select unique_id
from {{ info_schema('sources') }}
where unique_id not in (select parent_unique_id from {{ info_schema('edges') }})
  1. dbt check reports the unused source and exits 1:
    [error] [CheckFailed (dbt1650)]: check 'unused_source' failed with 1 violation(s)
    │ source.repro_source_selection.raw.unused_table │
  2. Select it, with any of these, and dbt check exits 0:
    dbt check --select 'source:*'
    dbt check --select 'source:raw.unused_table'
    dbt check --select 'resource_type:source'
    dbt check --select 'source.repro_source_selection.raw.unused_table'
    [warning] [NoNodesForSelectionCriteria (dbt1092)]: The selection criterion 'source:*' does not match any enabled nodes
  3. The selector resolves in dbt ls:
    $ dbt ls --select 'source:*'
    source:repro_source_selection.raw.orders
    source:repro_source_selection.raw.unused_table
  4. With a source and a model selected, the check is skipped:
    $ dbt check unused_source --select 'source:raw.orders+'
    [warning] [CheckSkipped (dbt1652)]: check 'unused_source' skipped: selection matched no nodes this check can report on
  5. State: run dbt parse and copy target/manifest.json to state_base/, then add identifier: orders_v2 to the orders table in models/sources.yml.
    $ dbt ls --select state:modified --state state_base
    source:repro_source_selection.raw.orders
    
    $ dbt check --select state:modified --state state_base
    [warning] [NoNodesForSelectionCriteria (dbt1092)]: The selection criterion 'state:modified' does not match any enabled nodes

Relevant log output

See the commands above. A model edit under state:modified is scoped correctly (dbt check --select state:modified reports the changed model), so only sources are affected.

What looks like the cause (public source)

Pointers are to dbt-labs/dbt-fusion at 9977b6c (2026-06-04), the most recent public snapshot. The dbt check code is not in that snapshot yet, so that part is described in words; I read a newer tree.

  • crates/dbt-scheduler/src/schedule.rs (~L289, schedule_graph): Schedule.all_selected_nodes keeps every selected node, while Schedule.selected_nodes is built with the comment "Apply exclusions: selected - sources - unused - extended_models", so it never contains sources. That is right for deciding what to run, since sources are not executable.
  • dbt check builds the set of nodes that scope a check's rows from Schedule.selected_nodes (in dbt-main, next to the code that calls scope_for_selection) rather than Schedule.all_selected_nodes. With a selector that only matches sources, the scope is empty, which is reported as "does not match any enabled nodes". A selector that matches a mix keeps only the non-source ids, so a check whose rows are sources reports nothing and is marked skipped.
  • Using all_selected_nodes for the scope (it also holds the other kinds dbt ls shows) should fix both the source selectors and state:modified for sources. I did not build the tree to confirm.

Related: #16553 (information schema constraints, found with the same dbt-project-evaluator port).

Environment

  • OS: macOS
  • CPU: ARM
  • dbt distribution and version: dbt 2.0.6

Which database adapter are you using?

duckdb (not adapter-specific)