Skip to content

Migrate baton-github to go-github v93 - #197

Merged
ggreer merged 3 commits into
mainfrom
paul.querna/upgrade-go-github-v93
Nov 9, 2026
Merged

ggreer merged 3 commits into
mainfrom
paul.querna/upgrade-go-github-v93

Conversation

@pquerna

@pquerna pquerna commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Migrate baton-github from go-github v69 to v93. The new client API takes construction options and returns errors; the connector now sets its existing HTTP transport and GitHub Enterprise URLs during construction. Custom enterprise endpoints continue to build URLs from a parsed url.URL and escaped path segments.

v93 also changes collaborator permissions from a map to typed fields. The connector explicitly maps the five GitHub flags back to its existing entitlement names, with a regression test for nil/false/all-true values. Organization invitations, team membership, repository collaborator grants, and role requests use v93's request types and signatures. The exported customclient.New signature remains unchanged.

The connector's PAT and GitHub App token-refresh transports remain in place; this PR changes the go-github API layer without replacing those authentication flows. The v69 module is no longer needed by this repository after go mod tidy.

Validation: go test ./... and go build ./cmd/baton-github passed. Local make lint could not start because the installed golangci-lint binary was built with Go 1.26, below this repo's Go 1.27.3 target; CI lint remains required.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@pquerna
pquerna requested a review from a team November 7, 2026 16:48
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit d063e65e37af

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: full
View review run

Review Summary

This PR swaps go-github v69 for v93. Client construction now goes through NewClient(opts...) with WithHTTPClient/WithEnterpriseURLs. Those options copy the http.Client but keep the same transport, so the oauth2/token-refresh transports still apply. Collaborator Permissions changed from map[string]bool to typed RepositoryPermissions. collaboratorPermissions maps it back to the existing pull/triage/push/maintain/admin slugs (pkg/connector/repository.go:27-31), so entitlement IDs stay the same (no B2 break) and grant order is now deterministic. Request types were renamed, and org-role REST paths are now built from url.PathEscaped segments. That is safe with v93's NewRequest, which resolves against the trailing-slash base URL and checks for path traversal. customclient.New keeps its signature and now re-parses client.BaseURL() (a string in v93). I checked the v93 vendored source for NewClient, WithEnterpriseURLs, BaseURL and NewRequest. FindOrganizationInstallation is now GetOrganizationInstallation and hits the same endpoint.

Scope: GitHub's diff endpoint refused the full PR diff (over 20,000 lines), so I read every non-vendor patch through the files API and scanned it for security and correctness. Vendored changes are limited to go-github/v69 (removed), go-github/v93 (added), go-querystring and modules.txt. That matches the go.mod/go.sum changes: v69 → v93 and an indirect go-querystring bump from 1.1.0 to 1.2.0, with no replace/exclude directives. Beyond the APIs listed above, I did not review the vendored upstream library code line by line.

I applied the repo-local criteria. No Grant/Revoke entity sources changed (P1/PR2), and no List/Grants error paths changed (S1–S6). Logging levels are unchanged (section A), and none of the new endpoints need new scopes (B7/B8). B10 does not apply: the endpoints are the same, only the client library changed.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit ed31d46fbee2

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: full
View review run

Review Summary

This PR swaps go-github v69 for v93. Client construction now goes through NewClient(opts...) with WithHTTPClient/WithEnterpriseURLs. Those options copy the http.Client but keep the same transport, so the oauth2/token-refresh transports still apply. Collaborator Permissions changed from map[string]bool to typed RepositoryPermissions. collaboratorPermissions maps it back to the existing pull/triage/push/maintain/admin slugs (pkg/connector/repository.go:27-31), so entitlement IDs stay the same (no B2 break) and grant order is now deterministic. Request types were renamed, and org-role REST paths are now built from url.PathEscaped segments. That is safe with v93's NewRequest, which resolves against the trailing-slash base URL and checks for path traversal. customclient.New keeps its signature and now re-parses client.BaseURL() (a string in v93). I checked the v93 vendored source for NewClient, WithEnterpriseURLs, BaseURL and NewRequest. FindOrganizationInstallation is now GetOrganizationInstallation and hits the same endpoint.

Scope: GitHub's diff endpoint refused the full PR diff (over 20,000 lines), so I read every non-vendor patch through the files API and scanned it for security and correctness. Vendored changes are limited to go-github/v69 (removed), go-github/v93 (added), go-querystring and modules.txt. That matches the go.mod/go.sum changes: v69 → v93 and an indirect go-querystring bump from 1.1.0 to 1.2.0, with no replace/exclude directives. Beyond the APIs listed above, I did not review the vendored upstream library code line by line.

I applied the repo-local criteria. No Grant/Revoke entity sources changed (P1/PR2), and no List/Grants error paths changed (S1–S6). Logging levels are unchanged (section A), and none of the new endpoints need new scopes (B7/B8). B10 does not apply: the endpoints are the same, only the client library changed.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.


Reviewed commit: d063e65e37af

@github-actions github-actions 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.

No blocking issues found — see the full review report

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit ed31d46fbee2

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: incremental since d063e65
View review run

Review Summary

This PR replaces go-github v69 with v93. Clients are now built with NewClient(WithHTTPClient, WithEnterpriseURLs), which returns an error. NewRequest takes the context and Do no longer does. Collaborator permissions are read from v93's typed RepositoryPermissions instead of a map. The org-role endpoints are now built from escaped path segments. Invitation, team, and collaborator calls use v93's request structs. customclient keeps the base URL as a string and re-parses it.

Coverage: gh pr diff refuses this diff because it is over 20k lines, almost all of it vendor. I scanned every non-vendor hunk through the PR files API for security and correctness. In the vendored v93 tree I checked only the parts this PR depends on: NewClient, WithHTTPClient, WithEnterpriseURLs, BaseURL(), Client() and the API-version header. The rest of the vendored code was not reviewed line by line.

What I verified:

  • Auth transports: the oauth2 and refreshable-token transports are still used. v93 copies the http.Client and adds its own auth wrapper only when WithAuthToken is set, which this PR doesn't do.
  • Enterprise URLs: /api/v3/ handling is unchanged.
  • API version: the default X-GitHub-Api-Version is still 2022-11-28.
  • Permission names: the five typed flags map to the same pull/triage/push/maintain/admin names the old map keys used (repository.go:27-31, :62-83). Entitlement slugs stay the same, and the new table test covers nil, false and all-true.
  • Dependencies: the go.mod/go.sum changes are the v69→v93 swap plus a go-querystring 1.1→1.2 bump that v93 pulls in. Neither is unrelated to the code changes. vendor/modules.txt lists v93 and drops v69.

How the repo criteria applied:

  • Provisioning (P1–P6/PR1–PR3): Grant/Revoke only change request types. Entity sources and argument order are unchanged.
  • No changes affect List, Entitlements or Grants error handling (S1–S6), log levels (A) or spans (C).
  • No endpoints, entitlement slugs or IDs changed, so B1–B10 don't apply.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 2650d134e977

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: incremental since d063e65
View review run

Review Summary

This PR replaces go-github v69 with v93. Clients are now built with NewClient(WithHTTPClient, WithEnterpriseURLs), which returns an error. NewRequest takes the context and Do no longer does. Collaborator permissions are read from v93's typed RepositoryPermissions instead of a map. The org-role endpoints are now built from escaped path segments. Invitation, team, and collaborator calls use v93's request structs. customclient keeps the base URL as a string and re-parses it.

Coverage: gh pr diff refuses this diff because it is over 20k lines, almost all of it vendor. I scanned every non-vendor hunk through the PR files API for security and correctness. In the vendored v93 tree I checked only the parts this PR depends on: NewClient, WithHTTPClient, WithEnterpriseURLs, BaseURL(), Client() and the API-version header. The rest of the vendored code was not reviewed line by line.

What I verified:

  • Auth transports: the oauth2 and refreshable-token transports are still used. v93 copies the http.Client and adds its own auth wrapper only when WithAuthToken is set, which this PR doesn't do.
  • Enterprise URLs: /api/v3/ handling is unchanged.
  • API version: the default X-GitHub-Api-Version is still 2022-11-28.
  • Permission names: the five typed flags map to the same pull/triage/push/maintain/admin names the old map keys used (repository.go:27-31, :62-83). Entitlement slugs stay the same, and the new table test covers nil, false and all-true.
  • Dependencies: the go.mod/go.sum changes are the v69→v93 swap plus a go-querystring 1.1→1.2 bump that v93 pulls in. Neither is unrelated to the code changes. vendor/modules.txt lists v93 and drops v69.

How the repo criteria applied:

  • Provisioning (P1–P6/PR1–PR3): Grant/Revoke only change request types. Entity sources and argument order are unchanged.
  • No changes affect List, Entitlements or Grants error handling (S1–S6), log levels (A) or spans (C).
  • No endpoints, entitlement slugs or IDs changed, so B1–B10 don't apply.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.


Reviewed commit: ed31d46fbee2

@github-actions github-actions 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.

No blocking issues found — see the full review report

Replace calls marked for inlining by go-github v93 with the standard new(value) syntax supported by the connector toolchain.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 2650d134e977

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: incremental since ed31d46
View review run

Review Summary

The new commit (2650d13) is a mechanical swap. It replaces every github.Ptr[T](x) call with Go's new(expr) pointer form in org.go, repository.go, team.go, usage_event_feed.go, the tests, and test/mocks/github.go. go.mod targets go 1.27.3, and new(expr) needs Go 1.26 or later, so that's fine. I checked that each inferred pointer type matches the old explicit one. invitationTestOrgID is declared as int64(12), so it doesn't fall back to *int. orgRoleAdmin and orgRoleMember are untyped string constants and become *string. No github.Ptr uses are left outside vendor/.

gh pr diff refuses this PR because it has more than 20,000 lines, mostly vendor/. So I scanned all 30 changed non-vendor files for security and correctness through the PR files API. That covers the v93 client construction and the GetOrganizationInstallation rename. It also covers the escaped path.Join org-role endpoints, the customclient base URL that is now a string and gets parsed and checked for scheme and host, the typed RepositoryPermissions mapping, and the v93 request types. I also checked go.mod/go.sum: v69 is swapped for v93, and go-querystring goes from 1.1 to 1.2 because v93 needs it. Both are explained by the code changes.

I applied the repo-local criteria wherever they were relevant:

  • Provisioning entity sources (PR2/PR3): unchanged.
  • Org-role and repo Grant/Revoke: argument order is unchanged.
  • Sync paths (S1/S5): no new skip or empty-result paths in Grants.
  • Logging, span, and JSON-type rules: no new log levels or spans; the API response struct changes come from the upstream library.

Coverage gap: I didn't review the 233 vendor/ files line by line. They are the upstream go-github v93 and go-querystring 1.2.0 sources that match the go.mod/go.sum changes.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Connector PR Review: Migrate baton-github to go-github v93

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base beaa4a2063a7.
Review mode: incremental since ed31d46
View review run

Review Summary

The new commit (2650d13) is a mechanical swap. It replaces every github.Ptr[T](x) call with Go's new(expr) pointer form in org.go, repository.go, team.go, usage_event_feed.go, the tests, and test/mocks/github.go. go.mod targets go 1.27.3, and new(expr) needs Go 1.26 or later, so that's fine. I checked that each inferred pointer type matches the old explicit one. invitationTestOrgID is declared as int64(12), so it doesn't fall back to *int. orgRoleAdmin and orgRoleMember are untyped string constants and become *string. No github.Ptr uses are left outside vendor/.

gh pr diff refuses this PR because it has more than 20,000 lines, mostly vendor/. So I scanned all 30 changed non-vendor files for security and correctness through the PR files API. That covers the v93 client construction and the GetOrganizationInstallation rename. It also covers the escaped path.Join org-role endpoints, the customclient base URL that is now a string and gets parsed and checked for scheme and host, the typed RepositoryPermissions mapping, and the v93 request types. I also checked go.mod/go.sum: v69 is swapped for v93, and go-querystring goes from 1.1 to 1.2 because v93 needs it. Both are explained by the code changes.

I applied the repo-local criteria wherever they were relevant:

  • Provisioning entity sources (PR2/PR3): unchanged.
  • Org-role and repo Grant/Revoke: argument order is unchanged.
  • Sync paths (S1/S5): no new skip or empty-result paths in Grants.
  • Logging, span, and JSON-type rules: no new log levels or spans; the API response struct changes come from the upstream library.

Coverage gap: I didn't review the 233 vendor/ files line by line. They are the upstream go-github v93 and go-querystring 1.2.0 sources that match the go.mod/go.sum changes.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.


Reviewed commit: 2650d134e977

@github-actions github-actions 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.

No blocking issues found — see the full review report

@ggreer
ggreer merged commit cf2e2d3 into main Nov 9, 2026
9 checks passed
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.

3 participants