brunoribeiro2k opened a new issue, #77800:
URL: https://github.com/apache/airflow/issues/77800
### Under which category would you file this issue?
Airflow Core
### Apache Airflow version
3.3.1
### What happened and how to reproduce it?
`airflow dags trigger --logical-date` stores the given logical date, but
infers the run's data interval from the trigger time instead of from that
logical date. The REST API (`POST /api/v2/dags/{dag_id}/dagRuns`, used by the
UI) infers it from the logical date, so the same request gets a different data
interval depending on how it is triggered.
Reproduce with a DAG on `CronDataIntervalTimetable`:
```python
import pendulum
from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.sdk import DAG
from airflow.timetables.interval import CronDataIntervalTimetable
with DAG(
"cron_interval_trigger_check",
schedule=CronDataIntervalTimetable("@monthly", timezone="UTC"),
start_date=pendulum.datetime(2026, 1, 1),
catchup=False,
):
EmptyOperator(task_id="noop")
```
Then, on 2026-11-30:
1. `airflow dags trigger cron_interval_trigger_check -r cli_feb15 -l
2026-02-15T00:00:00+00:00`
2. `POST /api/v2/dags/cron_interval_trigger_check/dagRuns` with
`{"dag_run_id": "api_feb16", "logical_date": "2026-02-16T00:00:00Z"}`
The stored runs:
| run_id | logical_date | data_interval_start | data_interval_end |
|---|---|---|---|
| `cli_feb15` | 2026-02-15 | 2026-10-01 | 2026-11-01 |
| `api_feb16` | 2026-02-16 | 2026-01-01 | 2026-02-01 |
The CLI run got the latest interval ended by the trigger time (October), not
the one before its logical date (January). The same happens with the default
cron timetable (`schedule="@monthly"`): the CLI run's zero-length interval sits
at the trigger time (2026-11-30), the API run's at its logical date
(2026-02-16). A custom timetable shows it too, since its
`infer_manual_data_interval` only receives the trigger time.
The cause looks to be in `airflow/api/common/trigger_dag.py`, which passes
`run_after` (now, for the CLI) to `infer_manual_data_interval` when a logical
date is given:
https://github.com/apache/airflow/blob/3.3.1/airflow-core/src/airflow/api/common/trigger_dag.py#L102-L106
The REST API passes the logical date instead:
https://github.com/apache/airflow/blob/3.3.1/airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_run.py#L252
The CLI tests check the stored logical date
(`test_trigger_dag_with_microseconds`) but not the data interval when a logical
date is given.
### What you think should happen instead?
With `--logical-date` set, the CLI should infer the data interval from the
logical date, as the REST API does, so `cli_feb15` gets 2026-01-01 to
2026-02-01. Without a logical date, the current behaviour (no logical date, no
data interval) is what `test_trigger_dag` expects and can stay.
### Operating System
Debian GNU/Linux 12 (bookworm), in the official image
### Deployment
Docker-Compose
### Apache Airflow Provider(s)
_No response_
### Versions of Apache Airflow Providers
_No response_
### Official Helm Chart version
Not Applicable
### Kubernetes Version
_No response_
### Helm Chart configuration
_No response_
### Docker Image customizations
`apache/airflow:3.3.1-python3.13` with extra pip requirements; none touch
the trigger path.
### Anything else?
It happens on every CLI trigger with `--logical-date`. Users who backfill
one interval from the CLI get a different interval than they asked for, with no
warning, and the CLI has no option to set the data interval by hand.
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]