Refactor to avoid potential future UnboundLocalError for producer_task in calculate_tasks_map#2309
Merged
Conversation
✅ Deploy Preview for astronomer-cosmos canceled.
|
16e571b to
465b411
Compare
465b411 to
4287f7c
Compare
4287f7c to
3f91e7a
Compare
UnboundLocalError for producer_task in calculate_tasks_map
3f91e7a to
f1109f5
Compare
f1109f5 to
d186a21
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2309 +/- ##
=======================================
Coverage 98.12% 98.12%
=======================================
Files 100 100
Lines 6733 6733
=======================================
Hits 6607 6607
Misses 126 126 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d186a21 to
a9e75b9
Compare
Contributor
Author
|
Happy to contribute to the project and glad to hear it'll be in the 1.13.1 release. @tatiana |
tatiana
pushed a commit
that referenced
this pull request
Feb 20, 2026
…task` in `calculate_tasks_map` (#2309) Fixed a potential scope issue where `producer_task` could be accessed before initialization in the `calculate_tasks_map` function. While I was digging through the watcher implementation, it became clear that the variable was only defined within a specific branch but referenced later in a separate block. Initializing it at the top and simplifying the downstream check makes the code much more robust against accidental crashes. Updating the logic to verify the presence of the task object itself instead of re-checking the execution mode keeps the flow consistent. This ensures the dependency setup only triggers when the producer is actually available. (cherry picked from commit c2731af)
Merged
tatiana
added a commit
that referenced
this pull request
Feb 25, 2026
**Enhancements** * Change Snowflake profile mappings to default to four threads by @tatiana in #2374 * Refactor to avoid potential future ``UnboundLocalError`` for ``producer_task`` in ``calculate_tasks_map`` by @rin in #2309 **Bug Fixes** * Fix graph selector when using + selector with ``dbt-loom`` by @award1230 in #2389 * Populate ``compiled_sql`` for ``InvocationMode.SUBPROCESS`` in ``ExecutionMode.WATCHER`` by @pankajkoti in #2319 * Preserve ``extra_context`` for watcher consumer task instances by @pankajkoti in #2381 * Fix watcher: respect ``deferrable=False`` from ``operator_args`` on consumer sensor by @pankajkoti in #2384 * Error handle invalid YAML with ``LoadMode.DBT_MANIFEST`` and ``RenderConfig.selector`` by @jonbillings in #2316 * Fix selecting model when it has the same name as folder by @pankajastro in #2328 * Handle Param Validation errors by @tatiana in #2358 * Fix cache swap issue by @jonbillings in #2332 * Fix leaked semaphore warnings in Airflow 3 by resetting dbt adapters by @pankajkoti in #2335 **Docs** * Document ``ExecutionMode.KUBERNETES`` limitations by @tatiana in #2326 **Others** * Add .airflow-registry.yaml for Airflow Provider Registry by @kaxil in #2387 * Improve test coverage for PR #2307 by @tatiana in #2308 * Address feedback from code review #2389 by @evanvolgas in #2394 Closes: astronomer/oss-integrations-private#333
Merged
tatiana
added a commit
that referenced
this pull request
Feb 25, 2026
Enhancements * Change Snowflake profile mappings to default to four threads by @tatiana in #2374 * Refactor to avoid potential future ``UnboundLocalError`` for ``producer_task`` in ``calculate_tasks_map`` by @rin in #2309 Bug Fixes * Fix graph selector when using + selector with ``dbt-loom`` by @award1230 in #2389 * Populate ``compiled_sql`` for ``InvocationMode.SUBPROCESS`` in ``ExecutionMode.WATCHER`` by @pankajkoti in #2319 * Preserve ``extra_context`` for watcher consumer task instances by @pankajkoti in #2381 * Fix watcher: respect ``deferrable=False`` from ``operator_args`` on consumer sensor by @pankajkoti in #2384 * Error handle invalid YAML with ``LoadMode.DBT_MANIFEST`` and ``RenderConfig.selector`` by @YourRoyalLinus in #2316 * Fix selecting model when it has the same name as folder by @pankajastro in #2328 * Handle Param Validation errors by @tatiana in #2358 * Fix cache swap issue by @YourRoyalLinus in #2332 * Fix leaked semaphore warnings in Airflow 3 by resetting dbt adapters by @pankajkoti in #2335 Docs * Document ``ExecutionMode.KUBERNETES`` limitations by @tatiana in #2326 Others * Add .airflow-registry.yaml for Airflow Provider Registry by @kaxil in #2387 * Improve test coverage for PR #2307 by @tatiana in #2308 * Address feedback from code review #2389 by @evanvolgas in #2394 Additional details on this change: - The actual release was done from branch 1.13: https://github.com/astronomer/astronomer-cosmos/releases/tag/astronomer-cosmos-v1.13.1 - This PR aims to update our CHANGELOG, and allow us to give credit to the username that was being questioned by codespell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed a potential scope issue where
producer_taskcould be accessed before initialization in thecalculate_tasks_mapfunction. While I was digging through the watcher implementation, it became clear that the variable was only defined within a specific branch but referenced later in a separate block. Initializing it at the top and simplifying the downstream check makes the code much more robust against accidental crashes.Updating the logic to verify the presence of the task object itself instead of re-checking the execution mode keeps the flow consistent. This ensures the dependency setup only triggers when the producer is actually available.