Repository navigation
Conversation
Connector PR Review: hard failure on getOrgBasePermission failureBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness. This change converts the previous silent fail-closed behavior (treating an absent The prior suggestion about documenting the new credential requirement is partly addressed: the Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. |
| "and skipping per-team detail fetches. Recommended for large orgs.", | ||
| "and skipping per-team detail fetches. Recommended for large orgs. "+ | ||
| "Requires the credential to be able to read the org's default repository permission "+ | ||
| "(admin:org scope or the Organization Administration read permission); "+ |
There was a problem hiding this comment.
You updated this config-field description to require the credential to read the org's default_repository_permission (admin:org scope / Organization Administration read), and validation + syncs now hard-fail without it when direct-collaborators-only is on — that's the right call. The gap is that the customer-facing docs weren't updated to match: docs/connector.mdx (credential/scopes section, ~L455-462) still doesn't list this new requirement, so an operator reading the docs won't know they need org-owner visibility before enabling this mode. Worth syncing that requirement into the docs in this PR.
There was a problem hiding this comment.
+1. Also docs/connector.mdx:77 still says read::org is fine if you're not provisioning (plus the :: typo), docs/docs-info.md:113 says the same thing, and the Optimize section says repo access data is "equivalent". All of those need the admin:org note.
FeliLucero1
left a comment
There was a problem hiding this comment.
Left a few notes. Logic looks right to me, main stuff is rebase + docs + a written-down rollout call on the ticket.
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/google/go-github/v69/github" |
There was a problem hiding this comment.
heads up: this won't compile once merged. Main is on go-github v93 now (#197) and NewClient returns (client, err) there. After rebasing, just use newTestGitHubClient(t, mgh.Server()) and drop this import. I tried it locally: with that change tests + lint pass.
| return nil, uhttp.WrapErrors(codes.PermissionDenied, "github-connector: credentials validation failed", err) | ||
| } | ||
|
|
||
| if err := gh.validateBasePermissionVisibility(ctx, firstAdminOrg); err != nil { |
There was a problem hiding this comment.
nothing actually tests this wiring (or the one in validateAppCredentials). The tests only hit the helper directly, so if someone deletes this call everything stays green. Could we add a quick gh.Validate(ctx) test against the mock, with and without the field?
| if org.GetDefaultRepoPermission() == "" { | ||
| err := fmt.Errorf( | ||
| "org %q did not return default_repository_permission; direct-collaborators-only requires it to sync org-member repo access correctly. "+ | ||
| "Grant the credential org-owner visibility (admin:org scope, the GitHub App Organization Administration permission, "+ |
There was a problem hiding this comment.
do we know for sure "Organization Administration" read is enough for App / fine-grained tokens? GitHub's docs for GET /orgs/{org} only mention org owner + admin:org (classic), and neither permissions page lists the GET under Administration. If it's not enough, App tenants have no fix except turning the flag off. Worth checking once with a real installation token before we tell customers to do this.
| "or fine-grained PAT organization Administration read access), or disable direct-collaborators-only", | ||
| orgLogin, | ||
| ) | ||
| return uhttp.WrapErrors(codes.PermissionDenied, "github-connector: credentials validation failed", err) |
There was a problem hiding this comment.
nit: this check + the error text are basically copy-pasted in getOrgBasePermission, and the two use different prefixes (github-connector: vs baton-github:). Maybe a small shared errMissingBasePermission(org) helper using baton-github:?
| // Org admins always have admin on all repos | ||
| adminEntitlementID := fmt.Sprintf("%s:%s:%s", resourceTypeOrg.Id, orgResID, orgRoleAdmin) | ||
| for _, perm := range repoAccessLevels { | ||
| return nil, nil, err |
There was a problem hiding this comment.
this is the intended behavior, but it's a breaking change: with v0.45 Validate runs at the start of every sync, so affected tenants stop syncing until their credential changes. Also, #178 already gives DoorDash correct data (their base perm really is none), so this makes things worse for the customer who reported the bug. Can we get the list of affected tenants + a short rollout note into the PR body / CXH-2100 before merging? Michael's "what's the reason" question on the ticket is still unanswered.
| "and skipping per-team detail fetches. Recommended for large orgs. "+ | ||
| "Requires the credential to be able to read the org's default repository permission "+ | ||
| "(admin:org scope or the Organization Administration read permission); "+ | ||
| "validation and syncs fail without it.", |
There was a problem hiding this comment.
config_schema.json still has the old description. Needs a make generate (after the rebase).
now, with more faulting.