leninworld opened a new pull request, #77808:
URL: https://github.com/apache/airflow/pull/77808

   This PR fixes [issue #77800](https://github.com/apache/airflow/issues/77800).
   
   `airflow dags trigger --logical-date` stored the given logical date, but 
`trigger_dag` inferred the run's data interval from the trigger time 
(`run_after`). The REST API (`POST /api/v2/dags/{dag_id}/dagRuns`) infers it 
from the logical date, so the same request got a different data interval 
depending on how it was triggered. For example, a monthly 
`CronDataIntervalTimetable` Dag triggered on 2026-11-30 with `-l 2026-02-15` 
got 2026-10-01 to 2026-11-01 instead of 2026-01-01 to 2026-02-01.
   
   `_trigger_dag` now passes the logical date to `infer_manual_data_interval`, 
as `TriggerDAGRunPostBody.validate_context` does. Without a logical date 
nothing changes: no logical date, no data interval. `run_after` is still used 
for the run id and stored on the run.
   
   `trigger_dag` is also used by the execution API, so a 
`TriggerDagRunOperator` with an explicit `logical_date` now gets the interval 
for that logical date too, instead of the one around the time the API call 
arrives. That matches the REST API, and Airflow 2.10's `trigger_dag`, which 
also called `infer_manual_data_interval(run_after=logical_date)`. When neither 
`logical_date` nor `run_after` is given, the operator uses the current time as 
the logical date, so the interval stays about the same.
   
   As with the REST API, a logical date in the future now gives a data interval 
that ends after `run_after`.
   
   Tests (run with `uv run --project airflow-core`):
   
   - New `test_trigger_dag_infers_data_interval_from_logical_date` fails on 
`main` (it gets 2026-10-01 to 2026-11-01) and passes with the fix. 
`test_trigger_dag.py`: 7 passed.
   - `execution_api/versions/head/test_dag_runs.py`: 33 passed.
   - `cli/commands/test_dag_command.py -k trigger`: 12 passed. One test, 
`test_trigger_dag_output_as_json`, could not be collected in my local `uv` 
environment (`ModuleNotFoundError: airflow_shared`), and it fails the same way 
on `main`.
   - `core_api/routes/public/test_dag_run.py` could not be collected locally 
for the same `airflow_shared` reason, so I did not run it.
   - `ruff format` and `ruff check` are clean on both files. I did not run mypy 
or the other prek and Breeze checks.
   
   closes: #77800
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Claude Opus 5.5) and OpenAI Codex following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.
   


-- 
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]

  • [PR] Infer the data interval f... leninworld (via GitHub) via commits

Reply via email to