Skip to content

Tag operation nodes with their hook type - #16319

Open
CallumFriend-MP wants to merge 3 commits into
dbt-labs:mainfrom
CallumFriend-MP:callumfriend/operation-tags
Open

CallumFriend-MP wants to merge 3 commits into
dbt-labs:mainfrom
CallumFriend-MP:callumfriend/operation-tags

Conversation

@CallumFriend-MP

@CallumFriend-MP CallumFriend-MP commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #16315 in part.

on-run-start and on-run-end operation nodes reach the manifest with tags: []. dbt-core tags each hook with its own hook type, which is what lets --select tag:on-run-start find them.

new_operation builds CommonAttributes with ..Default::default(), so tags never got set. operation_type is already a parameter and already used for the node name and fqn, so the tag comes from the same value. No new plumbing.

Verification

cargo check -p dbt-parser is clean. cargo test -p dbt-parser --lib gives 398 passed, 0 failed, 5 ignored, including resolve::resolve_operations::tests::dependency_package_hook_reads_root_project_name.

I also built a binary from this branch and ran it against a project with on-run-start: ["select 1"]:

operation.repro.repro-on-run-start-0 -> tags: ['on-run-start']

Stock 2.0.0rc2 gives tags: [] on the same project. dbt-core 1.12.0 gives ['on-run-start'].

One test fails that isn't mine: the --doc test resolve::validate_metrics::validate_metric_name (line 43) fails with E0432: unresolved import dbt_parser::resolve::validate_metric_name. I checked it against pristine main with my change reverted and it fails there identically.

Not included

#16315 also covers config being absent from operation.* nodes. dbt-core writes a fully resolved node config there: enabled, materialized: view, on_schema_change, project-level defaults like require_partition_filter, and so on.

That's a bigger change than this one. DbtOperation has no config field, and both serialized_config() and has_same_config() say operations have no config by design, so matching dbt-core means operations take part in config resolution. That seemed like your call rather than something to fold into a one-line PR, so I left it out and wrote it up on the issue.

It's also the half that actually bites. Manifest consumers that loop over every node and read node['config'] get a KeyError on these.

@CallumFriend-MP
CallumFriend-MP requested a review from a team as a code owner September 15, 2026 16:19
@cla-bot cla-bot Bot added the cla:yes label Sep 15, 2026
`on-run-start`/`on-run-end` operation nodes were built with
`..Default::default()` for `tags`, so they reached the manifest with `tags:
[]`. dbt-core tags each hook with its own hook type, which is what makes
`--select tag:on-run-start` reach them.

`operation_type` is already threaded into `new_operation` for the node name
and fqn, so the tag comes from the same value.

Fixes dbt-labs#16315 in part. That issue also covers `config` being absent from
these nodes entirely; dbt-core emits a fully resolved node config there,
which would require operations to participate in config resolution — left
out here as a separate decision.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2 Bug] operation.* nodes (on-run-start/end) lose both tags and config

1 participant