feat(environment): add service check before environment deletion#3728
Merged
Siumauricio merged 1 commit intocanaryfrom Feb 17, 2026
Merged
Conversation
- Implemented a new function to verify if an environment has active services before allowing its deletion. This prevents accidental deletion of environments that are still in use.
|
that was quick thanks |
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.
What is this PR about?
Please describe in a short paragraph what this PR is about.
Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
closes #3722
Screenshots (if applicable)
Greptile Summary
This PR adds server-side validation to prevent deletion of environments that still contain active services (applications, compose, mariadb, mongo, mysql, postgres, redis). A new
environmentHasServiceshelper checks if any service arrays are non-empty, anddeleteEnvironmentthrows aBAD_REQUESTerror if services exist.environmentHasServiceshelper function usingAwaited<ReturnType<typeof findEnvironmentById>>for type safetydeleteEnvironment, throwing a clear error message instructing users to delete services firstadvanced-environment-selector.tsx(defense in depth)onDelete: "cascade"on theenvironmentIdFK — this PR prevents the accidental cascade deletion of services when an environment is deleted directly (e.g., via API bypass of the frontend)Confidence Score: 5/5
environmentHasServicesfunction properly checks all seven service types that match the DB schema relations. The error handling follows existing patterns in the codebase. No regressions are expected since this only adds a new guard before deletion — existing callers that pass environments without services are unaffected.Last reviewed commit: 7e8d3b7