Repository navigation
server/services: add optional DeleteProject hook for plugin-owned project state - #9083
Closed
bujjibabukatta wants to merge 1 commit into
Closed
bujjibabukatta wants to merge 1 commit into
bujjibabukatta wants to merge 1 commit into
Conversation
Contributor
|
This doesn't make sense. You want plugins to depend on the backend/server package? Do you even understand the code you submitted? Please don't pick an issue you don't understand and generate random code, especially since the author of #9081 stated they will submit a PR for this matter. |
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.
Summary
Fixes #9081. The generic
DELETE /projects/:projectNameflow(
services.DeleteProject) has no lifecycle hook for plugins/featureswith project-scoped state, unlike
PatchProject's rename flow, whichalready calls
projectService.RenameProject(...). Feature-ownedrecords can be left stale or orphaned when a project is deleted
directly through this endpoint.
Root Cause
ProjectServiceonly definesRenameProject.DeleteProjectdeletescore records (project, mappings, metric settings, blueprint) with no
equivalent extension point, so any plugin/feature relying on its own
project-deletion flow to clean up state never gets invoked when
deletion happens through the core API.
Fix
ProjectDeleteHook, a separate optional interface (not a newrequired method on
ProjectService), so existing downstreamimplementations that only support renaming aren't broken.
DeleteProjectnow checks via type assertion whether the injectedprojectServicealso implementsProjectDeleteHook, and if soinvokes it inside the same deletion transaction, before core rows
are deleted — a hook error rolls back the whole deletion, and any
cleanup it performs commits atomically with core deletion.
Known limitation:
deleteProjectBlueprint(name)runs before thetransaction/hook, so a hook veto can't stop the blueprint from already
being deleted. Not addressed in this PR — flagging for a possible
follow-up.