Skip to content

refactor!: Rename InstallationTokenOptions to CreateInstallationTokenRequest, pass it by value, and remove CreateInstallationTokenListRepos - #4700

Merged
gmlewis merged 4 commits into
google:masterfrom
JamBalaya56562:refactor/3644-installation-token-request-types
Nov 6, 2026
Merged

gmlewis merged 4 commits into
google:masterfrom
JamBalaya56562:refactor/3644-installation-token-request-types

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Updates #3644.

BREAKING CHANGE: InstallationTokenOptions is renamed to CreateInstallationTokenRequest and AppsService.CreateInstallationToken now takes it by value; AppsService.CreateInstallationTokenListRepos and InstallationTokenListRepoOptions are removed in favor of AppsService.CreateInstallationToken, whose CreateInstallationTokenRequest.RepositoryIDs now uses omitzero so an empty slice is sent as [].

POST /app/installations/{installation_id}/access_tokens has a request body schema with only the optional repositories, repository_ids, and permissions, so no fields are added or removed. CreateInstallationTokenListRepos was added in #3155 (for #3106) only because omitempty could not send an empty repository_ids array. With json:"repository_ids,omitzero", CreateInstallationToken can send it: nil is omitted and []int64{} is sent as [], so the separate method and request type are no longer needed. Callers of CreateInstallationTokenListRepos can switch to CreateInstallationToken with RepositoryIDs: []int64{}. A caller that already passes an empty slice to CreateInstallationToken now sends [] instead of omitting the field.

With a value parameter, the zero value now sends {} instead of no body. I checked with a throwaway GitHub App (Metadata read, one selected repository) that no body, {}, {"repository_ids":null}, and {"repository_ids":[]} all return the same 201 response, and that each token can access the same repositories (GET /installation/repositories). InstallationTokenOptions and InstallationTokenListRepoOptions are removed from body-allowed-pointer-types and body-allowed-wrong-names, and the tests check the request body with testJSONBody and testJSONBodyRaw.

The method name already starts with the verb of the GitHub docs operation name ("Create an installation access token for an app"), so it is not renamed.

Verified locally: go build ./..., go vet -tags integration ./test/integration/, script/test.sh -covermode atomic ./... (all modules, without -race), script/generate.sh --check, script/lint.sh including custom-gcl, and script/check-schema-fields.sh reports nothing for this type. (It still reports the 4 EnterpriseUpdateBudget warnings that master has since #4693; #4699 fixes them.)

…stRepoOptions` to `...Request` types and pass them by value
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Oct 31, 2026
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (8faf371) to head (f0efe56).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4700      +/-   ##
==========================================
- Coverage   98.64%   98.64%   -0.01%     
==========================================
  Files         204      204              
  Lines       19089    19080       -9     
==========================================
- Hits        18831    18822       -9     
  Misses        258      258              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tools/schemafields/exceptions.txt Resolved
Comment thread github/apps.go Outdated
//
//meta:operation POST /app/installations/{installation_id}/access_tokens
func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id int64, body *InstallationTokenListRepoOptions) (*InstallationToken, *Response, error) {
func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id int64, body CreateInstallationTokenListReposRequest) (*InstallationToken, *Response, error) {

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.

If we change CreateInstallationTokenRequest.RepositoryIDs from omitempty to omitzero, we can remove the CreateInstallationTokenListRepos method, as it was introduced specifically to allow passing an empty RepositoryIDs slice. However, this would be a breaking change. Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, done in f0efe56: CreateInstallationTokenRequest.RepositoryIDs now uses omitzero, and CreateInstallationTokenListRepos and its request type are removed. The nil/empty/non-empty test moved to CreateInstallationToken. I also merged master to resolve the conflict.

…ateInstallationToken`

Use `omitzero` for `CreateInstallationTokenRequest.RepositoryIDs` so that
`CreateInstallationToken` can send an empty `repository_ids` array, which was
the only reason for the separate method and request type.
@JamBalaya56562 JamBalaya56562 changed the title refactor!: Rename InstallationTokenOptions and InstallationTokenListRepoOptions to ...Request types and pass them by value refactor!: Rename InstallationTokenOptions to CreateInstallationTokenRequest, pass it by value, and remove CreateInstallationTokenListRepos Nov 5, 2026

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra 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.

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Nov 6, 2026

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @JamBalaya56562 and @Not-Dhananjay-Mishra!
LGTM.
Merging.

@gmlewis
gmlewis merged commit dac8c26 into google:master Nov 6, 2026
15 checks passed
@JamBalaya56562
JamBalaya56562 deleted the refactor/3644-installation-token-request-types branch November 6, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants