Repository navigation
feat(environments): only the creator or an admin can destroy an API environment - #257
Merged
Merged
Conversation
vigneshrajsb
force-pushed
the
site-soft-delete
branch
from
October 9, 2026 17:46
4397c11 to
6fef0be
Compare
vigneshrajsb
force-pushed
the
env-destroy-creator-or-admin
branch
2 times, most recently
from
October 9, 2026 18:24
638a82f to
822edb1
Compare
vigneshrajsb
marked this pull request as ready for review
October 9, 2026 19:56
vmelikyan
approved these changes
Oct 9, 2026
vigneshrajsb
force-pushed
the
env-destroy-creator-or-admin
branch
3 times, most recently
from
October 9, 2026 20:54
1961796 to
c5381f3
Compare
…nvironment Enforced in BuildService.requestApiEnvironmentDeletion so the REST DELETE route and the destroy_environment MCP tool share one rule. Service keys keep their repository-allowlist scoping. The MCP preview refuses before issuing a confirmation token.
vigneshrajsb
force-pushed
the
env-destroy-creator-or-admin
branch
from
October 9, 2026 20:55
c5381f3 to
99309d7
Compare
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
Builds on #256 (merged).
Who can destroy: destroying an API-created environment is now allowed only for its creator (
createdByUserId) or a user with theadminrole. Anyone else gets403 forbidden_rolewith "Only the creator of this environment or an admin can destroy it."Where it's enforced: in
BuildService.requestApiEnvironmentDeletion, under the row lock, soDELETE /api/v2/environments/{uuid}and thedestroy_environmentMCP tool share one rule. The MCP preview phase checks the same rule, so it refuses before issuing a confirmation token.Environments with no recorded creator can only be destroyed by an admin.
Personal API keys act as their owner. Service keys are machine identities, so they keep their existing repository-allowlist scoping.
Behaviour notes:
DELETEon environments with no recorded creator (including PR-created ones) is now admin-only.Test plan
forbidden_rolewithout a token. Full Jest suite, lint, and server typecheck pass.DELETEand MCPdestroy_environmentpreview both returnforbidden_role; user A and an admin can destroy it.