Fix DbtSourceWatcherOperator template_fields inheritance#2226
Conversation
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
✅ Deploy Preview for astronomer-cosmos canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Update version to 1.12.1a1 for alpha release containing the DbtSourceWatcherOperator template_fields fix.
There was a problem hiding this comment.
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_fieldsto inherit fromDbtSourceLocalOperatorinstead ofDbtConsumerWatcherSensor - 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.
`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
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>
DbtSourceWatcherOperatorshould inherittemplate_fieldsfrom its parentDbtSourceLocalOperatorinstead ofDbtConsumerWatcherSensor. The previous assignment incorrectly included fields likemodel_unique_idthat do not exist on source operators, causingAttributeErrorwhen using sources with tests inExecutionMode.WATCHERwithSourceRenderingBehavior.WITH_TESTS_OR_FRESHNESS.closes: #2203