Skip to content

Remove two Dag list sort options that never worked - #75025

Merged
bbovenzi merged 1 commit into
apache:mainfrom
Pushkal-Gupta:fix-dag-sort-attributes
Oct 19, 2026
Merged

bbovenzi merged 1 commit into
apache:mainfrom
Pushkal-Gupta:fix-dag-sort-attributes

Conversation

@Pushkal-Gupta

@Pushkal-Gupta Pushkal-Gupta commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

GET /api/v2/dags says you can sort by state and start_date. Try either one and the request fails:

GET /api/v2/dags?order_by=state
AttributeError: type object 'DagModel' has no attribute 'state'

Neither column exists on DagModel. SortParam returns a clean 400 for a name that is not on its allowed list, but these two are on the list, so it skips that check and goes straight to getattr(self.model, name), which raises.

The UI endpoint behind /ui/dags lists the same two names and fails the same way.

Where they came from

#44345 moved the last-run sorts into to_replace:

-["dag_id", "dag_display_name", "next_dagrun", "last_run_state", "last_run_start_date"],
+["dag_id", "dag_display_name", "next_dagrun", "state", "start_date"],
 DagModel,
+{"last_run_state": DagRun.state, "last_run_start_date": DagRun.start_date},

The mapping is correct and both last_run_* names work. The mistake was writing the DagRun column names into the allowed list instead of deleting them. They have been advertised and broken ever since.

What this does

Removes the two names from both endpoints. Sorting by them now gets the same 400 as any other unknown attribute, and the spec stops offering them. last_run_state and last_run_start_date are untouched and remain the way to sort by the latest run.

I removed them rather than aliasing them onto DagRun.state and DagRun.start_date. The last_run_* spelling predates the refactor and already works, so a second name for the same sort felt worse than one. Happy to alias instead if you would rather keep the advertised names working.

Checks

Six tests, three per endpoint, covering state, start_date and -state. All six fail without the change, each with that AttributeError rather than a status code. test_dags.py for the public and UI routes is at 276 passed.

I checked the other 32 SortParam call sites the same way, 155 advertised attributes in all, including the keyword-argument form in hitl.py and the two in grid.py that take their attributes from timetable.run_ordering. These two endpoints were the only mismatches.

The spec, the private UI spec and the six generated UI files all come from their hooks and are stable on a second run. The only lines that change in them are the order_by descriptions.


Was generative AI tooling used to co-author this PR?
  • Yes - Claude Code (Opus 5)

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. labels Oct 18, 2026
@Pushkal-Gupta Pushkal-Gupta changed the title Fix sorting the Dag list by state or start_date Remove two Dag list sort options that never worked Oct 18, 2026
@bbovenzi bbovenzi added the backport-to-v3-4-test Backport to v3-4-test label Oct 19, 2026
@bbovenzi bbovenzi added this to the Airflow 3.4.0 milestone Oct 19, 2026
@bbovenzi
bbovenzi merged commit b8db2af into apache:main Oct 19, 2026
147 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

github-actions Bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 19, 2026
…apache#75025)

(cherry picked from commit b8db2af)

Co-authored-by: Pushkal Gupta <161060351+Pushkal-Gupta@users.noreply.github.com>
aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 19, 2026
…apache#75025)

(cherry picked from commit b8db2af)

Co-authored-by: Pushkal Gupta <161060351+Pushkal-Gupta@users.noreply.github.com>
vatsrahul1001 pushed a commit that referenced this pull request Oct 20, 2026
…#75025) (#75148)

(cherry picked from commit b8db2af)

Co-authored-by: Pushkal Gupta <161060351+Pushkal-Gupta@users.noreply.github.com>
vatsrahul1001 pushed a commit that referenced this pull request Oct 20, 2026
…#75025) (#75148)

(cherry picked from commit b8db2af)

Co-authored-by: Pushkal Gupta <161060351+Pushkal-Gupta@users.noreply.github.com>
vedntzz added a commit to vedntzz/Knack that referenced this pull request Oct 27, 2026
KN-5: no-alias-sort-keys rule from apache/airflow#75025 with real-cod…
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 area:UI Related to UI/UX. For Frontend Developers. backport-to-v3-4-test Backport to v3-4-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants