deepujain opened a new pull request, #73396:
URL: https://github.com/apache/airflow/pull/73396
**Title:** Clear error when branch operators lack logical date and dag run
When `use_task_logical_date=True`, `BranchDayOfWeekOperator` and
`BranchDateTimeOperator` crashed with `AttributeError: 'NoneType' object
has no attribute 'run_after'` whenever the task context contained neither
`logical_date` nor a `dag_run`. This raises a `ValueError` with an
actionable message instead, mirroring the existing behavior of
`DayOfWeekSensor`:
> Either `logical_date` or `run_after` should be provided in the task
context when `use_task_logical_date` is True
Fixes #72031
**Testing done**
- Added
`test_choose_branch_should_raise_when_neither_logical_date_nor_run_after`
to `test_weekday.py` and `test_datetime.py`. Verified both fail on the
old code and pass with the fix.
- Full operator test files pass (58 passed):
`providers/standard/tests/unit/standard/operators/test_weekday.py` and
`test_datetime.py`.
- `ruff format` and `ruff check` clean on all touched files.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Muse Spark (Meta) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]