sahilSENPAII opened a new issue, #77539:
URL: https://github.com/apache/airflow/issues/77539

   ### Description
   
   The public `GET /api/v2/backfills` endpoint requires `dag_id` and has no 
filters, so an API client can only list backfills for one Dag at a time.
   
   The UI-only `GET /ui/backfills` endpoint already supports:
   
   - an optional `dag_id`
   - an `active` filter (backfills with no `completed_at`)
   - range filters on `from_date`, `to_date`, `created_at`, `completed_at`, 
`max_active_runs` and `duration`
   - a `reprocess_behavior` filter
   - limiting results to Dags the user can read
   
   I'd like to bring the public endpoint closer to that:
   
   - make `dag_id` optional
   - apply the readable-Dags filter when `dag_id` is not given
   - add the date, `max_active_runs`, duration and `reprocess_behavior` 
filters, reusing the existing filter helpers
   
   No database schema change is needed. Existing calls that pass `dag_id` keep 
working as they do now.
   
   One open question: should `active` be exposed on the public endpoint? In 
#44624 there was hesitation because backfills have no status field, and 
"active" only means "not completed yet". If that's still a concern, I can leave 
`active` out and expose only the `completed_at` range filter.
   
   ### Use case/motivation
   
   Tools that use the public API (scripts, monitoring dashboards, alerting, 
airflowctl) can't answer simple questions like "which backfills are running 
right now?" or "which backfills finished in the last day?" in one request. 
Today they have to list every Dag, call `GET /backfills` once per Dag, then 
combine and filter the results themselves. On deployments with hundreds of 
Dags, that means hundreds of requests for one answer.
   
   The UI already gets this in a single call through `/ui/backfills`, but that 
endpoint is not a supported interface for API clients.
   
   `airflowctl` has the same limit: `BackfillOperations.list` requires a 
`dag_id`, so the CLI can't list backfills across Dags either.
   
   With this change, a client could get backfills across all the Dags it can 
read, filtered by dates or state, in one request, the same way the UI does.
   
   ### Related issues
   
   - #44396 / #44624: the UI-only `/ui/backfills` endpoint was added here, 
marked "UI-only API -- not public". In the #44624 review, extending the public 
endpoint instead was raised, and the public side was left for later.
   - #53049: request for filters on the Dag view Backfills tab. Its backend 
part landed in the UI-only endpoint (#70151, #71467, #74202).
   - #72897: open PR adding an Active/Completed filter to the Backfills tab, 
using the UI endpoint's `active` parameter.
   - #76493: open PR changing `requires_access_backfill` for `GET /backfills`. 
It touches the same route and tests, so I'd rebase on it if it merges first.
   - #68402: airflowctl command migration. `airflowctl` backfill list currently 
needs a `dag_id` for the same reason.
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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

Reply via email to