Repository navigation
feat(api-v3): add a pre_delete hook to the asset and organization deletes - #17147
Merged
Merged
Conversation
…etes build_assets_router and build_organizations_router take an optional pre_delete callable, called with the row and the request once the 404 and 403 checks pass and before the delete is run or queued for the async cascade. A downstream distribution can refuse a delete there by raising, the same way on_write lets it persist its own columns. The default is None, so open source behaves exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
blakeaowens
approved these changes
Dec 4, 2026
devGregA
approved these changes
Dec 4, 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.
Description
Adds an optional
pre_deletehook to the API v3 asset and organization delete routes, the same way the assets router already takeson_write.build_assets_router(pre_delete=...)andbuild_organizations_router(pre_delete=...)call the hook with the row and the request after the 404 and 403 checks pass, and before the delete runs or is queued for the async cascade (ASYNC_OBJECT_DELETE). A distribution that mounts these routers can refuse a delete by raising from the hook, and its registered exception handler renders the response. The default isNone, so open source behavior does not change: no extra query and no change in responses.Test results
unittests/api_v3/test_apiv3_pre_delete_hook.py(new, 10 tests, both routers):The tests call the router views directly, so they need neither the v3 mount nor a fixture, and they run on both
V3_FEATURE_LOCATIONSlegs. Ruff check and format are clean on the changed files.Documentation
No user-facing change: this is an extension point for code that builds the routers.
Checklist
dev.devbranch.🤖 Generated with Claude Code