Skip to content

Rename misleading last_automated_run param to reference_run#68714

Open
Lee-W wants to merge 1 commit into
apache:mainfrom
astronomer:fix-59618-reference-run
Open

Rename misleading last_automated_run param to reference_run#68714
Lee-W wants to merge 1 commit into
apache:mainfrom
astronomer:fix-59618-reference-run

Conversation

@Lee-W

@Lee-W Lee-W commented Jun 18, 2026

Copy link
Copy Markdown
Member

Why

DagModel.calculate_dagrun_date_fields took a keyword-only param named last_automated_run, implying it was always the most recent run.

It isn't: the scheduler passes whichever run it is currently processing, and in a distributed setup a newer run can be created concurrently. The name promised a guarantee the callers never provide.

This is a long-standing naming smell — the "last / latest" framing predates the current DagRun signature. The partition-driven scheduling work left a TODO ... See #59618 flagging it; this PR does that cleanup.

Closes: #59618

What

  • Rename the keyword-only param last_automated_runreference_run on DagModel.calculate_dagrun_date_fields, plus its three in-method references.
  • Rewrite the docstring: it's the run the scheduler is currently processing, used as the basis for the next-run calculation — not necessarily the latest.
  • Update both production callers (dag_processing/collection.py, jobs/scheduler_job_runner.py) and the two test callers.

No behaviour change — pure rename plus docstring clarification.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Claude] following the guidelines


  • Read the 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) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

The calculate_dagrun_date_fields parameter named last_automated_run is not
always the latest run: the scheduler passes whichever run it is currently
processing, and in a distributed system a newer run can be created
concurrently. The name implied a guarantee the callers do not provide.
Rename it to reference_run and document that it is the run used as the basis
for the next-run calculation, not necessarily the latest.

calculate_dagrun_date_fields is an internal scheduler method operating on
serialized dags and DB columns, not part of the public interface, so this is
not a user-facing breaking change.

related: apache#59618
@boring-cyborg boring-cyborg Bot added area:DAG-processing area:Scheduler including HA (high availability) scheduler labels Jun 18, 2026
@Lee-W Lee-W added the backport-to-v3-3-test Backport to v3-3-test label Jun 18, 2026
@Lee-W Lee-W marked this pull request as ready for review June 18, 2026 13:32
@Lee-W Lee-W requested review from amoghrajesh and jason810496 June 18, 2026 14:38

@phanikumv phanikumv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code changes look fine to me.

One quick observation: The commit body says related: while the PR description says Closes:. Both reference #59618. I think your intent was not to close it, am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:DAG-processing area:Scheduler including HA (high availability) scheduler backport-to-v3-3-test Backport to v3-3-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calculate_dagrun_date_fields doesn't understand how it is called

2 participants