Skip to content

fix(ui): delete policy attachments via controlled modal - #25324

Merged
yuneng-berri merged 7 commits into
BerriAI:litellm_yj_apr14from
Lucas-Song-Dev:fix-ui-policy-attachment-delete
Apr 14, 2026
Merged

fix(ui): delete policy attachments via controlled modal#25324
yuneng-berri merged 7 commits into
BerriAI:litellm_yj_apr14from
Lucas-Song-Dev:fix-ui-policy-attachment-delete

Conversation

@Lucas-Song-Dev

@Lucas-Song-Dev Lucas-Song-Dev commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Replace static Modal.confirm with DeleteResourceModal so attachment delete reliably triggers the API call. Add a regression test covering the confirm->delete flow.

Issue:
#25274

fix_issue_policy_attachment.mp4

Made-with: Cursor

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix

✅ Test

Changes

Replace static Modal.confirm with DeleteResourceModal so attachment delete reliably triggers the API call. Add a regression test covering the confirm->delete flow.

Made-with: Cursor
@vercel

vercel Bot commented Apr 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 14, 2026 5:14pm

Request Review

@Lucas-Song-Dev

Copy link
Copy Markdown
Contributor Author

@greptileai

@codspeed-hq

codspeed-hq Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing Lucas-Song-Dev:fix-ui-policy-attachment-delete (9c86973) with main (e64d98f)

Open in CodSpeed

@codecov

codecov Bot commented Apr 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Lucas-Song-Dev

Copy link
Copy Markdown
Contributor Author

@greptileai review this PR again

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a React 18 regression where Modal.confirm's onOk callback was not reliably invoked, causing attachment deletes to silently no-op. The fix replaces the static Modal.confirm with a controlled DeleteResourceModal backed by a new useDeletePolicyAttachment hook, and adds both unit and integration tests to cover the confirm→delete flow.

Confidence Score: 5/5

  • Safe to merge — the fix is well-scoped and well-tested; remaining findings are minor style issues only.
  • All findings are P2: an unused import and a missing React import in a test file. No logic bugs, security concerns, or data-integrity issues were found. The core fix correctly replaces an unreliable imperative modal with a controlled component pattern.
  • No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/policies/index.tsx Replaces Modal.confirm with a controlled DeleteResourceModal + useDeletePolicyAttachment hook; adds two pieces of state for the new modal. Contains a leftover unused useMutation import.
ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.ts New hook wrapping deletePolicyAttachmentCall in a useMutation; handles success/error messages and delegates callbacks cleanly.
ui/litellm-dashboard/src/components/policies/index.test.tsx New integration test for the attachment delete flow; mocks Modal.confirm as a no-op to verify the regression (old path) and confirms the new controlled modal path calls the API.
ui/litellm-dashboard/src/hooks/policies/useDeletePolicyAttachment.test.tsx Unit tests for the new hook covering success and error paths; missing import React for JSX wrapper function (minor).

Sequence Diagram

sequenceDiagram
    participant User
    participant AttachmentTable
    participant PoliciesPanel
    participant DeleteResourceModal
    participant useDeletePolicyAttachment
    participant deletePolicyAttachmentCall

    User->>AttachmentTable: clicks trash icon
    AttachmentTable->>PoliciesPanel: onDeleteClick(attachmentId)
    PoliciesPanel->>PoliciesPanel: "handleDeleteAttachmentClick()<br/>setAttachmentToDelete()<br/>setIsDeleteAttachmentModalOpen(true)"
    PoliciesPanel->>DeleteResourceModal: "renders (isOpen=true)"
    DeleteResourceModal->>User: shows confirm dialog

    User->>DeleteResourceModal: clicks "Delete"
    DeleteResourceModal->>PoliciesPanel: onOk()
    PoliciesPanel->>useDeletePolicyAttachment: mutate(attachmentId)
    useDeletePolicyAttachment->>deletePolicyAttachmentCall: call API
    deletePolicyAttachmentCall-->>useDeletePolicyAttachment: resolves

    alt success
        useDeletePolicyAttachment-->>PoliciesPanel: onSuccess → fetchAttachments()
        useDeletePolicyAttachment-->>PoliciesPanel: onSettled → close modal
    else error
        useDeletePolicyAttachment-->>PoliciesPanel: onError → MessageManager.error
        useDeletePolicyAttachment-->>PoliciesPanel: onSettled → close modal
    end
Loading

Reviews (7): Last reviewed commit: "fix(ui): remove unused useMutation impor..." | Re-trigger Greptile

Comment thread ui/litellm-dashboard/src/components/policies/index.tsx Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Tip:

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Comment thread ui/litellm-dashboard/src/components/policies/index.tsx Outdated
Comment thread ui/litellm-dashboard/src/components/policies/index.test.tsx
Adopt a React Query mutation for policy attachment deletion and add a pending-state test on the policies index panel. This removes local delete-loading state and keeps modal loading tied to mutation status.

Made-with: Cursor
@@ -57,6 +58,8 @@ const PoliciesPanel: React.FC<PoliciesPanelProps> = ({
const [isDeleting, setIsDeleting] = useState(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this will be handled by the new useMutation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only used by policy deletion not attachment, will create pr to refactor the policy deletion code

Comment thread ui/litellm-dashboard/src/components/policies/index.tsx Outdated
Comment thread ui/litellm-dashboard/src/components/policies/index.tsx Fixed
@gitguardian

gitguardian Bot commented Apr 14, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
29203053 Triggered Generic Password ef774a1 .circleci/config.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@yuneng-berri
yuneng-berri changed the base branch from main to litellm_yj_apr14 April 14, 2026 18:05
@yuneng-berri
yuneng-berri merged commit 3f3760b into BerriAI:litellm_yj_apr14 Apr 14, 2026
46 of 50 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…tachment-delete

fix(ui): delete policy attachments via controlled modal
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.

3 participants