Skip to content

Fix DbtSourceWatcherOperator template_fields inheritance#2226

Merged
pankajkoti merged 4 commits into
mainfrom
fix-source-watcher-template-fields
Dec 26, 2025
Merged

Fix DbtSourceWatcherOperator template_fields inheritance#2226
pankajkoti merged 4 commits into
mainfrom
fix-source-watcher-template-fields

Conversation

@pankajkoti
Copy link
Copy Markdown
Contributor

@pankajkoti pankajkoti commented Dec 24, 2025

DbtSourceWatcherOperator should inherit template_fields from its parent DbtSourceLocalOperator instead of DbtConsumerWatcherSensor. The previous assignment incorrectly included fields like model_unique_id that do not exist on source operators, causing AttributeError when using sources with tests in ExecutionMode.WATCHER with SourceRenderingBehavior.WITH_TESTS_OR_FRESHNESS.

closes: #2203

DbtSourceWatcherOperator should inherit template_fields from its parent
DbtSourceLocalOperator instead of DbtConsumerWatcherSensor. The previous
assignment incorrectly included fields like model_unique_id that do not
exist on source operators, causing AttributeError when using sources with
tests in watcher mode with SourceRenderingBehavior.WITH_TESTS_OR_FRESHNESS.

Fixes #2203
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 24, 2025

Deploy Preview for astronomer-cosmos canceled.

Name Link
🔨 Latest commit 05e0b58
🔍 Latest deploy log https://app.netlify.com/projects/astronomer-cosmos/deploys/694e51f9e7227000089fdce5

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.98%. Comparing base (057be02) to head (05e0b58).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2226   +/-   ##
=======================================
  Coverage   97.98%   97.98%           
=======================================
  Files          95       95           
  Lines        6190     6190           
=======================================
  Hits         6065     6065           
  Misses        125      125           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Update version to 1.12.1a1 for alpha release containing
the DbtSourceWatcherOperator template_fields fix.
Comment thread CHANGELOG.rst Outdated
@pankajkoti pankajkoti marked this pull request as ready for review December 26, 2025 07:09
Copilot AI review requested due to automatic review settings December 26, 2025 07:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in DbtSourceWatcherOperator where template_fields was incorrectly inherited from DbtConsumerWatcherSensor instead of its actual parent class DbtSourceLocalOperator. This caused AttributeError when using sources with tests in ExecutionMode.WATCHER mode because the inherited fields included model_unique_id which doesn't exist on source operators.

Key Changes:

  • Changed DbtSourceWatcherOperator.template_fields to inherit from DbtSourceLocalOperator instead of DbtConsumerWatcherSensor
  • Added test coverage to verify the correct template_fields inheritance
  • Updated version to 1.12.1a1

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cosmos/operators/watcher.py Fixed template_fields inheritance and added Sequence import for type annotation
tests/operators/test_watcher.py Added test to verify DbtSourceWatcherOperator doesn't include model_unique_id in template_fields
cosmos/init.py Bumped version to 1.12.1a1
CHANGELOG.rst Added changelog entry for the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pankajkoti pankajkoti added this to the 1.12.1 milestone Dec 26, 2025
@pankajkoti pankajkoti merged commit ebc74f9 into main Dec 26, 2025
88 checks passed
@pankajkoti pankajkoti deleted the fix-source-watcher-template-fields branch December 26, 2025 10:08
pankajkoti added a commit that referenced this pull request Dec 29, 2025
`DbtSourceWatcherOperator` should inherit `template_fields` from its
parent `DbtSourceLocalOperator` instead of `DbtConsumerWatcherSensor`.
The previous assignment incorrectly included fields like
`model_unique_id` that do not exist on source operators, causing
`AttributeError` when using sources with tests in
`ExecutionMode.WATCHER` with
`SourceRenderingBehavior.WITH_TESTS_OR_FRESHNESS`.

closes: #2203
@pankajkoti pankajkoti mentioned this pull request Dec 29, 2025
tatiana added a commit that referenced this pull request Jan 14, 2026
Bug Fixes

* Fix ``DbtSourceWatcherOperator.template_fields`` to inherit from
``DbtSourceLocalOperator`` instead of ``DbtConsumerWatcherSensor`` by
@pankajkoti in #2226
* Fix TypeError in Watcher mode with subprocess invocation by
@pankajkoti in #2227
* Error when RenderConfig.invocation_mode is incorrectly set by @tatiana
in #2267

Docs

* Fix minor documentation typo by @dnskr in #2093
* Fix default values in documentation by @dnskr in #2092
* Remove emit event for ExecutionMode.AIRFLOW_ASYNC limitation in docs
by @pankajastro in #2214

Others

* Add test to check profile metrics with non-Cosmos operator by
@pankajastro in #2215
* Fix CI main branch Airflow 2.6 tests by @tatiana in #2268

closes:
astronomer/oss-integrations-private#295

Co-authored-by: Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
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.

[Bug] DbtSourceWatcherOperator fails with object has no attribute 'model_unique_id'

3 participants