Skip to content

refactor!: Rename InstallationTokenOptions and InstallationTokenListRepoOptions to ...Request types and pass them by value - #4700

Open
JamBalaya56562 wants to merge 2 commits into
google:masterfrom
JamBalaya56562:refactor/3644-installation-token-request-types
Open

JamBalaya56562 wants to merge 2 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 InstallationTokenListRepoOptions is renamed to CreateInstallationTokenListReposRequest; AppsService.CreateInstallationToken and AppsService.CreateInstallationTokenListRepos now take them by value.

Both methods use POST /app/installations/{installation_id}/access_tokens, whose request body schema has only the optional repositories, repository_ids, and permissions, so no fields are added or removed. CreateInstallationTokenListReposRequest.RepositoryIDs changes from json:"repository_ids" to json:"repository_ids,omitzero": an empty array is still sent, which is why the method was added in #3155 (for #3106), and nil is now omitted instead of being sent as null, which the schema does not allow.

With a value parameter, the zero value now sends a body instead of no body: {} for both methods. For CreateInstallationTokenListRepos, passing an empty struct used to send {"repository_ids":null}. 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 names already start with the verb of the GitHub docs operation name ("Create an installation access token for an app"), so they are not renamed.

Verified locally: go build ./..., go vet -tags integration ./test/integration/, example module build, go test ./github/, generated files idempotent, custom-gcl 0 issues, and script/check-schema-fields.sh reports nothing for these types. (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 (eeb77ef) to head (d8e60bd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4700   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files         203      203           
  Lines       19027    19027           
=======================================
  Hits        18769    18769           
  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 Outdated
# although they are absent from the pinned repository creation request schemas.
#
# CreateInstallationTokenListReposRequest.RepositoryIDs has no omit option on purpose:
# CreateInstallationTokenListRepos exists to send repository_ids even when it is nil or

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.

omitempty tag on InstallationAccessTokenOptions.Repositories masking functionality of GitHub API

When creating an app installation access token through the REST API (POST /app/installations/{installation_id}/access_tokens), if the repositories parameter is set to an empty array, the API returns a list of all accessible repositories. However, the client currently strips empty arrays (omitempty) when marshaling the InstallationAccessTokenOptions.Repositories value making that functionality inaccessible through the client.

Can we use omitzero since it doesn't strip empty arrays?

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.

Done in d8e60bd. omitzero still sends [] and now omits nil instead of sending null, so I removed the exception and added a test for both. I had already checked with a throwaway GitHub App that null, [], and no field all return the same 201, and updated the PR description.

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). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants