Skip to content

fix(projects): add the creator as a project admin on create - #253

Merged
nazarli-shabnam merged 1 commit into
mainfrom
fix/project-creator-member
Jul 5, 2026
Merged

fix(projects): add the creator as a project admin on create#253
nazarli-shabnam merged 1 commit into
mainfrom
fix/project-creator-member

Conversation

@martian56

@martian56 martian56 commented Jul 5, 2026

Copy link
Copy Markdown
Member

What

Closes #125. Creating a project only inserted the projects row and never a project_members row for the creator. A regular workspace member who created a project was then blocked from its own admin-only settings, since requireProjectAdmin needs the caller to be a project admin or a workspace admin.

How

ProjectService.Create now inserts the creator as a project admin alongside the project. The new ProjectStore.CreateWithCreatorMember does both writes in one transaction, so a project can never exist without its creator being able to manage it. Workspace admins/owners are unaffected (they could already manage any project).

Testing

New internal/handler/project_create_member_test.go:

  • A regular workspace member creates a project, gets a project_members row with at least admin role, and can immediately PATCH the project settings (previously 403).
  • Creating a project adds exactly one membership, for the creator.

Full go test ./internal/handler ./internal/service green (no regressions).

AI assistance

Produced with the help of Claude Code (Claude Opus 4.8). AI-assisted commits carry a Co-Authored-By trailer.

Summary by CodeRabbit

  • New Features

    • Creating a project now automatically adds the creator as a project member with admin access.
    • Project creation now records the creator membership at the same time as the project itself.
  • Bug Fixes

    • Prevents projects from being created without an accompanying creator membership.
    • Ensures the created project ID is valid and immediately usable after creation.

Creating a project only inserted the projects row, so a regular workspace
member who created a project got no project_members row and was then blocked
from its admin-only settings (requireProjectAdmin needs project admin or a
workspace admin). Project creation now inserts the creator as a project admin
alongside the project in one transaction.

Closes #125

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@strix-security

strix-security Bot commented Jul 5, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for f997216.


Reviewed by Strix
Re-run review · Configure security review settings

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a6f27ee8-f323-4de8-b2f7-3c42da267170

📥 Commits

Reviewing files that changed from the base of the PR and between 22fe70e and f997216.

📒 Files selected for processing (3)
  • apps/api/internal/handler/project_create_member_test.go
  • apps/api/internal/service/project.go
  • apps/api/internal/store/project.go

📝 Walkthrough

Walkthrough

Project creation now creates a project_members row for the creator with admin role within the same transaction as project creation, via a new ProjectStore.CreateWithCreatorMember method used by ProjectService.Create. Tests verify creator admin membership and single-membership creation.

Changes

Creator membership on project creation

Layer / File(s) Summary
Transactional creator membership creation
apps/api/internal/store/project.go
Adds CreateWithCreatorMember, which inserts a project and its creator's project_members row in one GORM transaction.
Service wiring for creator admin role
apps/api/internal/service/project.go
ProjectService.Create now calls CreateWithCreatorMember with RoleAdmin instead of the plain Create call, with added documentation.
Tests for creator membership behavior
apps/api/internal/handler/project_create_member_test.go
Adds tests confirming the creator gets an admin-level project_members row, can perform an admin-only settings update, and that exactly one active membership row exists for the created project.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: strix-security

Poem

A rabbit hops in, creates a nest,
No longer locked out, admin blessed!
One row for the founder, snug and true,
Settings unlocked with a single view. 🐇
Hop, commit, and transaction complete —
A tidy burrow, safe and neat!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is conventional, concise, and clearly describes adding the creator as a project admin on project creation.
Description check ✅ Passed It covers the bug, approach, tests, and AI disclosure, though some template sections are omitted.
Linked Issues check ✅ Passed The change satisfies #125 by creating creator membership in one transaction and adding tests for admin-only access and membership count.
Out of Scope Changes check ✅ Passed The diff stays focused on the creator-membership fix and related tests, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/project-creator-member

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands.

@martian56 martian56 self-assigned this Jul 5, 2026
@martian56 martian56 added this to the Finish w Enhancements milestone Jul 5, 2026
@martian56 martian56 added bug Something isn't working API labels Jul 5, 2026
@martian56
martian56 requested a review from nazarli-shabnam July 5, 2026 07:54

@nazarli-shabnam nazarli-shabnam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done!

@nazarli-shabnam
nazarli-shabnam merged commit d5ad35a into main Jul 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Project creators are not added as project members

2 participants