Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(init): allow org admins to create projects when member creation is disabled - #1284

Merged
MathurAditya724 merged 1 commit into
mainfrom
fix/init-admin-project-creation
Jul 22, 2026
Merged

MathurAditya724 merged 1 commit into
mainfrom
fix/init-admin-project-creation

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Problem

sentry init on org test101-n4 fails with:

✖  Setup failed.
   Project creation is disabled for members in "test101-n4".

...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) used hasOrgWriteAccess(organization.access) which only checked for org:write in the access scopes.

In Sentry's role hierarchy (verified against SENTRY_ROLES in sentry/conf/server.py):

Role org:write project:write project:admin
member - - -
admin - ✓ ✓
manager ✓ ✓ ✓
owner ✓ ✓ ✓

The admin role has project:write and project:admin but NOT org:write. The check was more restrictive than the actual Sentry API, which allows admins to create projects.

Fix

Replace the narrow hasOrgWriteAccess (checked only org:write) with canBypassMemberCreationRestriction which recognizes org:write, project:admin, and project:write — matching the actual server-side permission model.

Tests

Added 3 new test cases:

  • Admin with project:admin scope can proceed
  • User with project:write scope can proceed
  • Admin with project:admin scope can proceed even when listTeams returns 403

All 30 tests pass.

…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
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1284/

Built to branch gh-pages at 2026-07-22 19:34 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 66.67%. Project has 5488 uncovered lines.
✅ Project coverage is 81.69%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/init/preflight.ts 66.67% ⚠️ 1 Missing and 1 partials
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

@MathurAditya724
MathurAditya724 merged commit 7019b60 into main Jul 22, 2026
31 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/init-admin-project-creation branch July 22, 2026 19:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant