ENG-2755: Add DELETE /dsr/policy/{policy_key} endpoint with in-use guard#7459
Merged
ENG-2755: Add DELETE /dsr/policy/{policy_key} endpoint with in-use guard#7459
Conversation
Adds a new endpoint to delete DSR policies by key. Returns 409 Conflict if the policy is referenced by any privacy requests, preventing orphaned records. Child rules and rule targets are cascade-deleted via the existing Policy.delete() method. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Contributor
Greptile SummaryAdds a
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 9301db7 |
Add db.expire_all() after the DELETE API call so the test session re-queries the database instead of returning cached objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move PrivacyRequest import to top of policy_endpoints.py - Move PrivacyRequest import to top of test file - Remove redundant DataCategory import in test (already at module level) - Remove unnecessary manual cleanup in test_delete_policy_in_use Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
galvana
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket ENG-2755
Description Of Changes
Add a
DELETE /api/v1/dsr/policy/{policy_key}endpoint that allows users to remove DSR policies they no longer need. The endpoint guards against deleting policies that are actively referenced by privacy requests — returning a 409 Conflict in that case to prevent orphaned records. Child Rule and RuleTarget records are cascade-deleted via the existingPolicy.delete()method.Code Changes
src/fides/api/api/v1/endpoints/policy_endpoints.py- Adddelete_policyDELETE handler with 404/409/204 responses, secured byPOLICY_DELETEscopetests/ops/api/v1/endpoints/test_policy_endpoints.py- AddTestDeletePolicyclass with 5 tests covering auth, not found, in-use conflict, and successful cascade deletionSteps to Confirm
PATCH /api/v1/dsr/policywith a rule and targetDELETE /api/v1/dsr/policy/{policy_key}→ expect 204 No Content, verify policy, rules, and targets are removedPOLICY_DELETEscope → expect 403 ForbiddenPre-Merge Checklist
CHANGELOG.mdupdated