Skip to content

feat: add bulk DAG-run deletion in web UI#2009

Merged
yottahmd merged 3 commits intomainfrom
bulk-delete-dag-runs
Apr 18, 2026
Merged

feat: add bulk DAG-run deletion in web UI#2009
yottahmd merged 3 commits intomainfrom
bulk-delete-dag-runs

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Apr 18, 2026

Summary

  • add a DELETE DAG-run API endpoint and generated client/server bindings
  • prevent deleting latest aliases or active DAG-runs while removing completed run data through the existing store cleanup path
  • add a bulk Delete selected action to the DAG-runs UI with confirmation, progress, and result reporting

Testing

  • go test ./internal/service/frontend/api/v1 -run 'TestDeleteDAGRun' -count=1
  • pnpm test src/features/dag-runs/components/common/tests/DAGRunBatchActions.test.tsx
  • pnpm typecheck
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Added the ability to delete DAG runs individually and in batches through the UI.
    • Implemented safeguards to prevent deletion of active DAG runs; users must stop or dequeue them first.
    • Delete operations include validation and appropriate error messaging for invalid requests.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6ff10d62-7658-4094-aaa0-daad5c8fc798

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds DAG run deletion functionality across the API specification, backend service, and frontend UI. It introduces a DELETE endpoint for concrete DAG run IDs (excluding 'latest'), enforces authorization and state validation, and provides batch deletion capabilities in the UI with confirmation dialogs.

Changes

Cohort / File(s) Summary
API Specification
api/v1/api.yaml
Added DELETE /dag-runs/{name}/{dagRunId} operation with deleteDAGRun ID; introduced new DAGRunConcreteId path parameter (string, pattern-validated, non-'latest'); defined response mappings for 204, 400, 404, and default error cases.
Backend Implementation
internal/service/frontend/api/v1/dagruns.go, dagruns_test.go
Implemented DeleteDAGRun handler with developer-level authorization, rejection of 'latest' alias (400), lookup via dagRunStore.FindAttempt, prevention of active run deletion (400), removal via dagRunStore.RemoveDAGRun, audit logging, and 404 handling. Added three test cases covering success, latest-rejection, and active-run rejection scenarios.
Frontend Schema & Types
ui/src/api/v1/schema.ts, ui/src/features/dag-runs/hooks/useDAGRunBatchSubmission.ts
Updated TypeScript schema to enable DELETE method on /dag-runs/{name}/{dagRunId} path, added DAGRunConcreteId parameter type; extended BatchActionType union to include 'delete' and implemented DELETE request logic in submitBatchItem with remoteNode query parameter.
Frontend UI
ui/src/features/dag-runs/components/common/DAGRunBatchActions.tsx, __tests__/DAGRunBatchActions.test.tsx
Added delete batch action with destructive button styling, localized labels, delete-specific warning/confirmation UI, and success message ("Delete request accepted"). Refactored submit button text generation into shared getSubmitButtonText helper. Added test case verifying DELETE request parameters and state updates.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Frontend UI
    participant Hook as useDAGRunBatchSubmission
    participant API as API Handler<br/>(DeleteDAGRun)
    participant Auth as Authorization
    participant Store as DAGRunStore
    participant Log as Audit Log

    User->>UI: Click "Delete selected" batch action
    UI->>UI: Show confirmation dialog<br/>with delete warning
    User->>UI: Confirm deletion
    UI->>Hook: submitBatchItem(action='delete',<br/>name, dagRunId, remoteNode)
    Hook->>API: DELETE /dag-runs/{name}/{dagRunId}<br/>?remoteNode=...
    API->>Auth: Check developer authorization
    Auth-->>API: ✓ Authorized
    API->>API: Validate dagRunId !== 'latest'
    API->>Store: FindAttempt(name, dagRunId)
    Store-->>API: DAG run attempt + status
    API->>API: Check if status.IsActive()
    alt Active Run
        API-->>Hook: HTTP 400 (stop/dequeue first)
        Hook-->>UI: Show error message
    else Inactive Run
        API->>Store: RemoveDAGRun(name, dagRunId)
        Store-->>API: ✓ Deleted
        API->>Log: Log audit event<br/>(dag_run_delete)
        Log-->>API: ✓ Logged
        API-->>Hook: HTTP 204 No Content
        Hook-->>UI: { ok: true }
        UI->>UI: Show "Delete request accepted"
        UI->>UI: Update selection (clear)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add bulk DAG-run deletion in web UI' directly matches the main objective of adding a bulk deletion feature to the DAG-runs UI, accurately summarizing the primary change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bulk-delete-dag-runs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
ui/src/features/dag-runs/hooks/useDAGRunBatchSubmission.ts (1)

111-230: Guard against implicit fallthrough to reschedule.

submitBatchItem dispatches retry and delete explicitly but treats every other value as reschedule. If a new BatchActionType is added to the union in the future, it will silently fall through and perform a reschedule — which for a destructive or unrelated action would be a correctness bug. Consider a switch(action) with an exhaustive never check (or an explicit if (action === 'reschedule') guard with a final throw).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/features/dag-runs/hooks/useDAGRunBatchSubmission.ts` around lines 111
- 230, submitBatchItem currently treats any action other than 'retry' and
'delete' as a reschedule, causing silent fallthrough if BatchActionType later
expands; update submitBatchItem to use a switch(action) (or an explicit if
(action === 'reschedule') branch) and add an exhaustive check that throws on
unknown actions (use a never/assertUnreachable pattern) so new/invalid actions
fail fast instead of implicitly performing reschedule.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/v1/api.yaml`:
- Around line 6936-6945: The DAGRunConcreteId schema currently allows the
literal "latest" but must reject it for concrete/delete endpoints; update the
DAGRunConcreteId schema (the name DAGRunConcreteId and its pattern field in the
spec) to explicitly exclude "latest" (for example by using a negative lookahead
in the regex such as one that rejects the exact string "latest" while still
allowing the existing [a-zA-Z0-9_-]+ tokens), save the OpenAPI spec, and then
regenerate the server (run make api) so the updated validation is applied.

In `@internal/service/frontend/api/v1/dagruns.go`:
- Around line 1721-1750: TOCTOU: ensure the active-state check and removal are
atomic by either acquiring the per-run lock before reading status or moving the
guard into RemoveDAGRun so it is checked under the same lock; specifically, in
the handler around attempt.ReadStatus and a.dagRunStore.RemoveDAGRun, acquire
the same per-run synchronization used by DequeueDAGRun (or call a dagRunStore
method that does so), then re-read status while holding the lock and refuse
deletion if status.IsActive(); alternatively, implement the active-state check
inside RemoveDAGRun (under its lock) so RemoveDAGRun atomically rejects active
runs before removing.

---

Nitpick comments:
In `@ui/src/features/dag-runs/hooks/useDAGRunBatchSubmission.ts`:
- Around line 111-230: submitBatchItem currently treats any action other than
'retry' and 'delete' as a reschedule, causing silent fallthrough if
BatchActionType later expands; update submitBatchItem to use a switch(action)
(or an explicit if (action === 'reschedule') branch) and add an exhaustive check
that throws on unknown actions (use a never/assertUnreachable pattern) so
new/invalid actions fail fast instead of implicitly performing reschedule.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a49f7af-c314-4ad7-aafd-fcd814312e8c

📥 Commits

Reviewing files that changed from the base of the PR and between 5211cbb and 593b7fb.

📒 Files selected for processing (8)
  • api/v1/api.gen.go
  • api/v1/api.yaml
  • internal/service/frontend/api/v1/dagruns.go
  • internal/service/frontend/api/v1/dagruns_test.go
  • ui/src/api/v1/schema.ts
  • ui/src/features/dag-runs/components/common/DAGRunBatchActions.tsx
  • ui/src/features/dag-runs/components/common/__tests__/DAGRunBatchActions.test.tsx
  • ui/src/features/dag-runs/hooks/useDAGRunBatchSubmission.ts

Comment thread api/v1/api.yaml Outdated
Comment thread internal/service/frontend/api/v1/dagruns.go Outdated
@yottahmd yottahmd merged commit b22c3e6 into main Apr 18, 2026
11 checks passed
@yottahmd yottahmd deleted the bulk-delete-dag-runs branch April 18, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant