Skip to content

fix: let every member of an organization see who starred its commits through the API - #1619

Open
simonhamp wants to merge 1 commit into
dev-null-sh:productionfrom
simonhamp:fix/api-org-commit-stars
Open

simonhamp wants to merge 1 commit into
dev-null-sh:productionfrom
simonhamp:fix/api-org-commit-stars

Conversation

@simonhamp

@simonhamp simonhamp commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On the web, any member of an organization can open the list of who starred one of its commits. ListCommitStarsRequest checks Commit::isOwnedBy(), so the organization's commits count as every member's own.

The signed API checked user_id instead, which is the member who posted the commit. So through the API only that one member got the list and every other member got a 404. The mobile app (NativePHP/dev-null-app#182) treats an organization's commits as every member's, as the web does, and it currently has to tell the other members that only the poster can see who starred it.

This brings the API in line with the web.

Changes

  • ListApiCommitStarsRequest now uses $commit->isOwnedBy($user), the same check as ListCommitStarsRequest. Every other API commit request already used it.
  • The list itself is unchanged. It only holds the people who starred the commit, so nothing in it says which member posted it.
  • One line in the signed API list in KNOWLEDGE_BASE.md.

API

GET /api/v1/commits/{commit}/stars

Who asks Before After
Author of a person's own commit 200 200
Org member who posted the commit 200 200
Another member of the org 404 200
Poster who has since left the org 200 404
Non-member, site admin included 404 404
Unsigned 401 401

Validation

Local, PHP 8.5.12, PostgreSQL with its own test database:

  • New tests in tests/Feature/Controllers/Api/CommitStarControllerTest.php for org commits: the poster and another member get the list, while someone outside the org, a site admin outside it and a poster who left get 404. The "another member" and "poster who left" cases fail on unchanged production. The existing tests for a person's own commits and for unsigned requests pass unchanged.
  • vendor/bin/pint --test on the changed files: pass
  • rector --dry-run: pass
  • phpstan: pass, no errors
  • pest --type-coverage --min=100: 100%
  • Relevant files (Api/CommitStarControllerTest, the web CommitStarControllerTest, OrganizationCommitsTest, ArchTest): 87 passed
  • Whole suite, serially with --ci: 6223 tests, 6221 passed and 2 failed. Both are in tests/Feature/Controllers/GuildMembershipControllerTest.php and fail the same way on unchanged production here. The local Vite build is older than the new guild members page, so that page can't render. They are not from this change.
  • Coverage: not run, there is no coverage driver (pcov or Xdebug) on this machine. Both sides of the changed line are tested, but CI is the real check.
  • bun run test:unit, test:lint, test:types: not run, no JS or TS changed.

Independent review

A read-only Claude review agent with the repo's .ai/guidelines and the diff against production at 88f2ea0, head 964359d: CODE: PASS. It confirmed the API and web checks are now the same line, and pointed out the one behaviour change, covered below. Visual review doesn't apply, nothing in the UI changed.

Limitations

  • A member who posted an organization's commit and then left the organization can no longer read its stars through the API. The web already works this way.

Summary by CodeRabbit

  • New Features
    • Organization members can view who starred commits owned by their organization. Other users continue to see only the star count.
  • Documentation
    • Clarified that stargazer lists include organization-owned commits and are ordered newest first, with 20 entries per page.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The API now allows organization members to list stargazers for organization commits through ownership-based authorization. Tests cover access for members and 404 responses for nonmembers. The Signed API documentation now includes organization commits.

Changes: Organization commit star visibility

Layer / File(s) Summary
Organization-aware star-list authorization
app/Http/Requests/ListApiCommitStarsRequest.php, tests/Feature/Controllers/Api/CommitStarControllerTest.php, KNOWLEDGE_BASE.md
Authorization uses Commit::isOwnedBy($user). Tests cover members, nonmembers, site admins who are not members, and former members. The API documentation includes organization commits. Both the newest-first order and 20-per-page details remain.

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

Change: Bug fix

Possibly related PRs

Suggested reviewers: sulimanbenhalim, mnapoli

Merge Risk: Minimal · up to 96435

Organization members can now list who starred their organization's commits through the API, matching the web behavior. A member who posted a commit and later left the organization loses that access, as intended. Nothing found blocks merging; the remaining comment only suggests a test improvement.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: organization members can now see who starred the organization's commits through the API. The raw summary and objectives confirm this change in ListApiCommitStarsReque…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: organization members can now see who starred the organization's commits through the API. The raw summary and objectives confirm this change in ListApiCommitStarsRequest authorization and its tests. The title is specific and matches the changeset. It uses the fix: prefix, which fits a behavior correction. The title is 84 characters, slightly long but still a single clear sentence.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@simonhamp
simonhamp marked this pull request as ready for review November 18, 2026 15:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional comments: 1

tests/Feature/Controllers/Api/CommitStarControllerTest.php: 1

280-280: Trivial · Maintainability & Code Quality · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Test access before and after the poster leaves.

This case creates an organization commit for a poster who was never a member. It checks the 404 for a non-member, but it cannot catch a leave operation that fails to remove the membership. Add a test that gets 200 for the poster, uses the application's leave workflow, then gets 404 for the same poster and commit.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e4e6bf68-547e-4d9e-b373-cdd73feccf58
Commits

Reviewing files that changed from the base of the PR and between 88f2ea0 and 964359d.

Files selected for processing: 3

  • KNOWLEDGE_BASE.md
  • app/Http/Requests/ListApiCommitStarsRequest.php
  • tests/Feature/Controllers/Api/CommitStarControllerTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant