Skip to content

DayOfWeekSensor is failing when logical date is null and argument 'use_task_logical_date' is True #47717

Description

@atul-astronomer

/### Apache Airflow version

3.0.0b2

If "Other Airflow 2 version" selected, which one?

No response

What happened?

DayOfWeekSensor is failing when logical date is null and argument 'use_task_logical_date' is True

  • Task failed with exception logger="task" error_detail=[{"exc_type":"KeyError","exc_value":"'logical_date'","syntax_error":null,"is_cause":false,"frames":[{"filename":"/opt/airflow/task_sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":609,"name":"run"},{"filename":"/opt/airflow/task_sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":730,"name":"_execute_task"},{"filename":"/opt/airflow/airflow/models/baseoperator.py","lineno":168,"name":"wrapper"},{"filename":"/opt/airflow/airflow/sensors/base.py","lineno":287,"name":"execute"},{"filename":"/opt/airflow/airflow/sensors/base.py","lineno":267,"name":"execute"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/sensors/weekday.py","lineno":107,"name":"poke"}]}]

What you think should happen instead?

DayOfWeekSensor should work with null logical date and argument 'use_task_logical_date'=True

How to reproduce

Run the below DAG:

from pendulum import today

from airflow import DAG
from airflow.providers.standard.sensors.weekday import DayOfWeekSensor

with DAG(
    "example_week_sensor",
    schedule=None,
    start_date=today('UTC').add(days=-2),
    tags=[ "sensor"],
) as dag:
    working_day_check = DayOfWeekSensor(
        task_id="working_day_check",
        # added weekend days so that no matter what any day of the week this sensor will work.
        week_day={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
        use_task_logical_date=True,
        poke_interval=20.0,
        timeout=120.0,
        dag=dag,
    )

Operating System

Linux

Versions of Apache Airflow Providers

No response

Deployment

Other

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions