Grant the project creator an owner role on creation - #660
Open
silentsudo-io wants to merge 1 commit into
Open
Conversation
A newly created project gets no project_member row at all, so it has no roles whatsoever. Two consequences: * it cannot be shared -- the Collaborators UI has no roles to work with, so the owner cannot add anyone, including themselves; * with GLOBAL_ADMIN=True, the creator cannot see their own project. GlobalWorkspaceHandler.get_user_role returns GUEST for non-superusers, and a GUEST reaches a project only via project_member or Project.public, so projects_query(ProjectPermissions.Read) filters it out before the flag=created creator test is ever reached. Both project creation paths are affected: add_project and clone_project. Neither called set_role. ProjectRole was already imported. Fixes MerginMaps#659 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Fixes #659.
The problem
add_project()never grants the creator a role, so a new project ends up with no rows inproject_memberat all. Two consequences:GLOBAL_ADMIN=True, the creator cannot see their own project.GlobalWorkspaceHandler.get_user_role()returnsGUESTfor non-superusers, and aGUESTreaches a project only viaproject_memberorProject.public. Soprojects_query(ProjectPermissions.Read)filters the project out before theflag=createdcreator test is reached —GET /v1/project/paginated?flag=createdreturnscount=0for the user who just created it.The change
p.set_role(current_user.id, ProjectRole.OWNER)before the commit, in both creation paths:add_project()clone_project()— same omission, same effect on a cloned projectProjectRolewas already imported in the module, so this adds no imports.set_role()appends to theproject_usersrelationship, which cascades on commit, so it works on the still-pendingProject.Notes for reviewers
set_role()firesproject_access_granted. It will now fire for the creator on every project creation. That seemed semantically right — access was granted — but if you would rather not emit it for the creator, say so and I will restructure.project_memberrows. A data migration grantingownertocreator_idwhere a project has no members would repair them. Happy to add one to this PR if you want it here rather than separately.Verified against
Reproduced on self-hosted CE, backend image
2025.7.3, single global workspace,GLOBAL_*all at defaults. Two projects created by two different users via two different paths (web UI and REST API) both landed with zero member rows.add_project()is structurally unchanged from2025.7.3through2026.6.2, so this affects all of them.CLA: I have added
silentsudo-ioto the individual CLA list inLICENSES/CLA-signed-list.mdin this PR.