Repository navigation
Make repository grant and revoke direct-only with direct-collaborators-only - #199
c1-squire-dev[bot] wants to merge 2 commits into
Conversation
…s-only With the flag on, Grant returned GrantAlreadyExists for users who had access only through a team or org base permission. Effective-access checks hid the missing direct record, and the sync lists only direct collaborators, so the grant never appeared. With the flag on, Grant now always calls AddCollaborator. Revoke removes only the direct collaborator, treats a 404 as already revoked, and logs a warning when team or org access remains. Behavior with the flag off is unchanged. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
|
|
||
| resp, er := o.client.Repositories.RemoveCollaborator(ctx, repo.GetOwner().GetLogin(), repo.GetName(), user.GetLogin()) | ||
| if er != nil { | ||
| alreadyRevoked := o.directCollaboratorsOnly && resp != nil && resp.StatusCode == http.StatusNotFound |
There was a problem hiding this comment.
🟡 Suggestion (medium confidence): GitHub documents DELETE /repos/{owner}/{repo}/collaborators/{username} as returning 204, 403, or 422. A 404 is not its "not a collaborator" answer; GitHub uses 404 to hide permission failures. Treating any 404 as already revoked can report a revoke as successful when the token could not perform it. The new test only passes because the mock invents a 404 for non-collaborators. Consider removing the 404 carve-out, or documenting the vendor's 404 semantics on this call and checking IsCollaborator/direct membership before reporting success.
| var replacedGrantID string | ||
| if collaborator { | ||
| permLevel, resp, err := o.client.Repositories.GetPermissionLevel(ctx, repo.GetOwner().GetLogin(), repo.GetName(), user.GetLogin()) | ||
| if !o.directCollaboratorsOnly { |
There was a problem hiding this comment.
🟡 Suggestion: With the flag on, the GrantReplaced annotation is dropped even for users who are already direct collaborators. Example: a direct admin user is granted pull. AddCollaborator downgrades them, but C1 keeps the stale admin/maintain/push grants until the next sync. The PR description says this is deliberate. Still, a direct-only lookup (e.g. ListCollaborators with Affiliation: "direct" filtered to the login, or the sync's direct-collaborator source) would keep the replaced-grant signal without reintroducing the team-access short-circuit.
| `--sync-last-activity` — emit the audit-log usage event feed. Hidden from `--help` and from the GUI config here, because it only applies to GitHub Enterprise audit-log access; `baton-github-enterprise` sets it directly instead of going through this CLI layer | ||
| `--omit-archived-repositories` — skip archived repositories | ||
| `--direct-collaborators-only` — reduce API calls on large organizations | ||
| `--direct-collaborators-only` — reduce API calls on large organizations. With this option on, repository grants create a direct collaborator record, and repository revokes remove only that record. Access through teams is separate and is not changed |
There was a problem hiding this comment.
🟡 Suggestion: The customer-facing docs/connector.mdx section "Optimize sync for large organizations" (around lines 494-504) was not updated. It still says repository access data "is equivalent" and does not mention that, with this option on, grants always create a direct collaborator and revokes leave team/org access in place. Please add the same note there (D1/BP3).
There was a problem hiding this comment.
Added a direct-only grant and revoke note to the Optimize sync section in docs/connector.mdx in commit 7d9ce4c.
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
Describe direct-only grant and revoke behavior in the Optimize sync section. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Superseded — see the current review report for commit
|
Connector PR Review: Make repository grant and revoke direct-only with direct-collaborators-onlyBlocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryWhen I scanned the full PR diff for security and correctness problems. The incremental diff was complete, with no dropped paths and no truncation. I applied the trusted repo-local criteria:
Security IssuesNone found. Correctness IssuesNone found. Suggestions
Resolved prior findings
Prompt for AI agentsReviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
Summary
With
direct-collaborators-onlyon,GrantreturnedGrantAlreadyExistsfor a user who had access only through a team or org base permission. The effective-access check short-circuited beforeAddCollaborator. The sync lists only direct collaborators in this mode, so the grant never appeared. This regressed in #174.With the flag on,
Grantnow always callsAddCollaboratorand drops theGrantReplacedlookup.Revokeremoves only the direct collaborator, treats a 404 as already revoked, and logs a warning if team or org access remains. Behavior with the flag off is unchanged. The option description and docs now explain this.config_schema.jsonwas regenerated from the built binary.Testing
go build ./...: passgo vet ./...: passgo test ./...: pass (new tests cover grant with the flag on and off, revoke of a non-direct user, and revoke with team access remaining)golangci-lint run: 0 issues🤖 Generated with Claude Code