Skip to content

Add a Dag bundle detail page listing the files in the bundle - #73009

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:dag-bundles-detail
Sep 21, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
astronomer:dag-bundles-detail

Conversation

@kaxil

@kaxil kaxil commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Depends on #72909. This branch carries that PR's commit as its base, so the diff here shows
both. The change to review is the second commit,
c0b2f0d. Draft until #72909
lands, at which point this rebases down to one commit. A fork branch cannot be used as a base on
apache/airflow, so there is no way to scope the diff on GitHub before then.

Builds on #72909, which adds the Dag Bundles list. This adds the page behind each row.

Summary

GET /api/v2/dagBundles/{bundle_name} and GET /api/v2/dagBundles/{bundle_name}/files, plus a detail page showing a bundle's files with the Dags each one defines, when it was last parsed, how long that took, and its import-error count.

A bundle's files, with a broken file offering its error

Clicking a file's error count opens the stack trace behind it:

The stack trace behind that error

The bundle name on the list is now a link into it:

The Dag Bundles list with linked bundle names

Why the list alone is not enough

The list answers "has my commit landed". It does not answer "what in it is broken", and there is one case where nothing else in the UI answers it either: a file that fails before defining a Dag. There is no DagModel row for it, so no per-Dag view mentions it, and the bundle's import-error count says only that something somewhere is wrong. That file is exactly what someone opens this page to find, and it is the first row in the screenshot above.

Design rationale

The file list has two sources. Files holding a Dag the caller may read are aggregated from dag. Files that recorded an import error without registering a Dag are added separately, because they have no Dag to authorize on, on the same admin-by-default terms as GET /importErrors.

Parse times come from the Dags in the file, not the file. That is the only record Airflow keeps: a file whose Dags were all removed keeps no parse time of its own.

The stack trace is read through GET /importErrors, not returned with the file list. A stack trace is unbounded and the file list is polled, so shipping one per row would bloat a request made every ten seconds. That endpoint already has bundle_name and filename filters and already decides who may read an import error, so this adds no endpoint and no authorization surface. It renders in DagImportErrorModal, which moves from pages/Dag to components now that a second page uses it -- components/DagDeactivatedBanner was already reaching across into pages for it, which was backwards. A dialog rather than a page of its own, because a single stack trace is not worth an addressable route.

dag_count counts live Dags, and a file is listed on the strength of a live Dag or an error. Dag rows are never deleted. A file that fails to import has every Dag in it marked stale by update_dag_parsing_results_in_db, and a file dropped from the bundle gets the same from deactivate_deleted_dags. Counting stale rows would over-report in the one case this page exists to diagnose, and would disagree with GET /dags, which excludes stale Dags by default. Keying the listing on staleness alone would be worse in the other direction: a file that had just broken would vanish from the page opened to find out why. Hence the two conditions, which is also why first.py in the screenshot shows 0 Dags, a stale parse time from when it last worked, and an error.

Both routes 404 rather than 403 for a bundle that exists but holds no readable Dag, so a response cannot be used to confirm which bundle names a deployment has.

Alternatives considered

A SQL UNION ALL for the two halves of the file list. Rejected: the halves differ in both shape and authorization, the union needs typed NULL casts to line the columns up across dialects, and the set being merged is one bundle's files. Merging in the api-server is the smaller thing to read. The cost is that the whole file list is read to answer one page, which the endpoint's docstring says.

A separate "Import errors" section instead of folding error-only files into the table. Two tables with clean semantics each, but it splits "what is in this bundle and is it healthy" across two places, and the interesting row is precisely the one that would move to the second table.

Exposing the bundle classpath and its configured kwargs. Both are in the prototype this is modelled on, and both are left out. The classpath means reading dag_bundle_config_list in the api-server, which is the reason refresh_interval stayed out of #72909. Bundle kwargs are free-form and a plausible home for credentials, so rendering them into a response is a leak waiting to happen.

A third-level page per file. The file row already carries everything the page has to say about that file, and its error opens in place, so a separate route would add a URL for a page with nothing extra on it.

Goal alignment

Airflow already records every field here. Nothing new is written, there is no migration, no new role, and no new writable surface: this reads dag, dag_bundle and import_error rows the Dag processor already maintains. It is the same read-only shape as #72909, which keeps it clear of the objection on #61645 about runtime mutation of bundle configuration.

Anticipated objections

"Why no order_by?" The rows are assembled outside the database, so a SortParam bound to a model cannot order them and the endpoint takes no sort parameter rather than pretending to. Files are returned ordered by path and the table declares no sortable columns. Server-side sorting is worth adding when someone has a bundle where it matters.

"Is dag_count on the detail response not just the file list's total?" No. dag_count counts Dags; the file total counts files, and includes error-only files the Dag count cannot see.

Gotchas

  • A file that holds Dags, none of which the caller may read, is excluded entirely rather than shown with a zero count, so the caller cannot infer its existence.
  • A bundle from which no Dag has ever parsed 404s, inherited from the visibility rule in Show Dag bundle versions and refresh times in the UI #72909.
  • import_error_count per file is at most 1, since import_error holds one row per file.

Follow-ups

  • A version history tab, from DagVersion.bundle_version. Worth doing with a clear label, because it has the blind spot Show Dag bundle versions and refresh times in the UI #72909 describes: a commit whose every Dag failed to import never produces a DagVersion row.
  • Linking a file's Dag count to the Dags list filtered by that bundle and file. The API has a bundle_name filter; the UI does not yet.

@kaxil
kaxil requested review from XD-DENG and ashb as code owners September 12, 2026 22:56

@amoghrajesh amoghrajesh 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.

I wonder if we could use better UX for the import error button, on a file inside bundle. The 1 inside the box isnt too intuitive to be a clickable to me.

Needs a rebase otherwise mostly fine

@kaxil
kaxil force-pushed the dag-bundles-detail branch from c0b2f0d to 8ac2036 Compare September 16, 2026 22:31
@kaxil

kaxil commented Sep 16, 2026 •

Copy link
Copy Markdown
Member Author

I wonder if we could use better UX for the import error button, on a file inside bundle. The 1 inside the box isnt too intuitive to be a clickable to me.

Needs a rebase otherwise mostly fine

Rebased, and updated the UX. Now, its an outlined button with a warning icon and a label now, "View error" (or "View N errors"), which lines up with how the dashboard shows import errors. Refreshed the screenshots in the description. wdyt?

A bundle's files, with a broken file offering its error

The stack trace behind that error

@kaxil
kaxil force-pushed the dag-bundles-detail branch from 8ac2036 to 58ae683 Compare September 17, 2026 03:15
@kaxil
kaxil requested a review from amoghrajesh September 17, 2026 03:15

@bbovenzi bbovenzi 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.

UI lgtm, just one nit

Add GET /api/v2/dagBundles/{bundle_name} and
GET /api/v2/dagBundles/{bundle_name}/files, and a page behind each row of the Dag
Bundles list showing the bundle's files with the Dags each one defines, when it
was last parsed, how long that took, and its import-error count.

The list view answers "has my commit landed" but not "what in it is broken". The
gap it cannot close is a file that fails before defining a Dag: there is no
DagModel row for it, so no per-Dag view in the UI mentions it, and the bundle's
import-error count says only that something is wrong. That file is exactly what
someone opens this page to find.

Files therefore come from two sources. Files holding a Dag the caller may read
are aggregated from dag, which is also the only record of parse time and
duration Airflow keeps -- a file whose Dags were all removed keeps none of its
own. Files that recorded an import error without registering a Dag are added on
the same admin-by-default terms as GET /importErrors, since they have no Dag to
authorize on. The two halves are merged in the api-server rather than unioned in
the database: they differ in shape and in authorization, and the set being merged
is one bundle's files.

Dag rows are never deleted, which decides what the counts can mean. A file that
fails to import has every Dag in it marked stale by
update_dag_parsing_results_in_db, and a file dropped from the bundle has the same
done by deactivate_deleted_dags. So dag_count counts live Dags only, agreeing
with GET /dags, which excludes stale Dags by default -- counting them would
over-report in the one case the page exists to diagnose. A file then stays listed
on the strength of a live Dag or an import error, rather than of a Dag row: a
file that has just broken keeps its row instead of vanishing, and a file deleted
long ago drops out instead of lingering with a count of Dags that no longer
exist.

A file's import-error count opens the stack trace behind it, read through
GET /importErrors rather than returned with the file list: a stack trace is
unbounded and the file list is polled, and that endpoint already decides who may
read an import error. It renders in DagImportErrorModal, which moves from
pages/Dag to components now that a second page uses it -- components already
reached across into pages for it, which was backwards.

Staleness decides the parse columns too. last_parsed_time is the file's last
known parse, so a broken file still says when it last worked, while
last_parse_duration is taken from live rows only: a Dag removed from a file keeps
its row frozen at an older, slower parse, and an unrestricted MAX would pair that
duration with the newer timestamp and report a parse that never happened.

Both routes resolve the bundle through the same filter the collection route uses,
so a bundle holding no registered Dag is reachable on exactly the terms the
collection grants it, and a bundle the caller may not see is a 404 rather than a
403 -- a response cannot be used to confirm which bundle names a deployment has.

Neither the bundle classpath nor its configured kwargs are exposed. The classpath
would mean reading dag_bundle_config_list in the api-server, which is the reason
refresh_interval stayed out, and bundle kwargs are free-form and a plausible home
for credentials.
@kaxil
kaxil force-pushed the dag-bundles-detail branch from 58ae683 to 3311783 Compare September 21, 2026 22:20
@kaxil
kaxil merged commit 3a94412 into apache:main Sep 21, 2026
155 of 156 checks passed
@kaxil
kaxil deleted the dag-bundles-detail branch September 21, 2026 23:34
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run details

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
❌ airflow-ctl/v0-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 3a94412 airflow-ctl/v0-1-test

This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants