Skip to content

Conversation

@NilsJPWerner
Copy link
Contributor

In Airflow 3.x, commit 035060d (PR #46616) changed the trigger_dag module to use DagRun.generate_run_id() instead of
dag.timetable.generate_run_id() for manual DAG runs. This bypassed custom timetable logic, causing a regression from Airflow 2.x behavior.

This commit restores the use of dag.timetable.generate_run_id() for manual triggers, allowing custom timetables to control run_id generation for both scheduled and manually triggered runs.

Changes:

  • airflow/api/common/trigger_dag.py: Changed to call dag.timetable.generate_run_id() with run_after and data_interval parameters instead of DagRun.generate_run_id()
  • tests/api_fastapi/core_api/routes/public/test_dag_run.py: Added test to verify custom timetable generate_run_id is called for manual triggers with both logical_date provided and null

This pattern matches how manual triggers are handled in other parts of the codebase (e.g., assets.py, scheduler_job_runner.py).

Fixes: #55908


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg
Copy link

boring-cyborg bot commented Oct 3, 2025

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Oct 3, 2025
@NilsJPWerner
Copy link
Contributor Author

cc @sunank200 @uranusjr

@NilsJPWerner
Copy link
Contributor Author

NilsJPWerner commented Oct 13, 2025

A little bump on this. Would love to get this in for 3.1.1 @kaxil

@pierrejeambrun pierrejeambrun added this to the Airflow 3.1.1 milestone Oct 13, 2025
@pierrejeambrun pierrejeambrun added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Oct 13, 2025
Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I'll wait for another pair of eyes.

@pierrejeambrun
Copy link
Member

CI need fixing.

@NilsJPWerner
Copy link
Contributor Author

CI need fixing.

They seem unrelated to my changes. I rebased but it didn't seem to retrigger ci

In Airflow 3.x, commit 035060d (PR apache#46616) changed the trigger_dag
module to use DagRun.generate_run_id() instead of
dag.timetable.generate_run_id() for manual DAG runs. This bypassed
custom timetable logic, causing a regression from Airflow 2.x behavior.

This commit restores the use of dag.timetable.generate_run_id() for
manual triggers, allowing custom timetables to control run_id generation
for both scheduled and manually triggered runs.

Changes:
- airflow/api/common/trigger_dag.py: Changed to call
  dag.timetable.generate_run_id() with run_after and data_interval
  parameters instead of DagRun.generate_run_id()
- tests/api_fastapi/core_api/routes/public/test_dag_run.py: Added test
  to verify custom timetable generate_run_id is called for manual
  triggers with both logical_date provided and null

This pattern matches how manual triggers are handled in other parts of
the codebase (e.g., assets.py, scheduler_job_runner.py).

Fixes: apache#55908
@pierrejeambrun
Copy link
Member

I just rebased the PR, lets see if the CI is happy now.

@pierrejeambrun
Copy link
Member

static check need fixing, this is related to your code change.

@NilsJPWerner
Copy link
Contributor Author

static check need fixing, this is related to your code change.

Sorry I misread the position of the ruff check. I have fixed it now.

@uranusjr
Copy link
Member

Need to fix test, otherwise this makes sense to me.

@NilsJPWerner
Copy link
Contributor Author

When fixing the tests I realized I also needed to fix this in the fastapi endpoint.

@uranusjr uranusjr merged commit c28b211 into apache:main Oct 16, 2025
214 of 215 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 16, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

github-actions bot pushed a commit that referenced this pull request Oct 16, 2025
…l triggers (#56373)

(cherry picked from commit c28b211)

Co-authored-by: Nils Werner <[email protected]>
@github-actions
Copy link

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 16, 2025
…l triggers (apache#56373)

(cherry picked from commit c28b211)

Co-authored-by: Nils Werner <[email protected]>
potiuk pushed a commit that referenced this pull request Oct 16, 2025
…l triggers (#56373) (#56699)

(cherry picked from commit c28b211)

Co-authored-by: Nils Werner <[email protected]>
@NilsJPWerner NilsJPWerner deleted the issue-46616 branch October 16, 2025 20:15
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 17, 2025
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 19, 2025
TyrellHaywood pushed a commit to TyrellHaywood/airflow that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom timetable generate_run_id function no longer used for manually triggered dag runs

4 participants