fix(init): allow org admins to create projects when member creation is disabled - #1284
Merged
Merged
Conversation
…s disabled The preflight check in `assertOrgScopedCreationCanProceed` only checked for `org:write` scope to bypass the `allowMemberProjectCreation` flag. In Sentry's role hierarchy, the `admin` role has `project:write` and `project:admin` but NOT `org:write` (only `manager` and `owner` have it). This caused org admins to see the misleading error: "Project creation is disabled for members in <org>" The fix broadens the scope check to also recognize `project:write` and `project:admin`, which correctly identifies admin/manager/owner roles as capable of creating projects regardless of the member creation flag. Verified against SENTRY_ROLES in sentry/conf/server.py: - member: project:read only — correctly blocked - admin: project:write, project:admin — now allowed - manager: org:write — already allowed - owner: org:write — already allowed
Contributor
|
Contributor
Codecov Results 📊❌ Patch coverage is 66.67%. Project has 5488 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.68% 81.69% +0.01%
==========================================
Files 426 426 —
Lines 29969 29971 +2
Branches 19496 19499 +3
==========================================
+ Hits 24479 24483 +4
- Misses 5490 5488 -2
- Partials 2045 2045 —Generated by Codecov Action |
5 tasks
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.
Problem
sentry initon orgtest101-n4fails with:...even though the user is an org admin, not a member.
Root Cause
The preflight check in
assertOrgScopedCreationCanProceed(src/lib/init/preflight.ts:376-381) usedhasOrgWriteAccess(organization.access)which only checked fororg:writein the access scopes.In Sentry's role hierarchy (verified against
SENTRY_ROLESinsentry/conf/server.py):org:writeproject:writeproject:adminThe
adminrole hasproject:writeandproject:adminbut NOTorg:write. The check was more restrictive than the actual Sentry API, which allows admins to create projects.Fix
Replace the narrow
hasOrgWriteAccess(checked onlyorg:write) withcanBypassMemberCreationRestrictionwhich recognizesorg:write,project:admin, andproject:write— matching the actual server-side permission model.Tests
Added 3 new test cases:
project:adminscope can proceedproject:writescope can proceedproject:adminscope can proceed even whenlistTeamsreturns 403All 30 tests pass.