Use int64 for GitHub database IDs#13403
Draft
williammartin wants to merge 1 commit into
Draft
Conversation
Change all struct fields representing GitHub database IDs from int to int64 to match the API spec and prevent potential overflow on 32-bit architectures. Add a custom go/analysis linter (idtype-checker) that flags struct fields with ID-like names or JSON tags using int instead of int64, integrated into make lint. Closes #9247 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
int64for GitHub database IDsCloses #9247
Problem
Several structs in the CLI use Go's
inttype for GitHub database ID fields. Go'sintis platform-dependent and could be 32-bit on some architectures, while GitHub internally uses 64-bit integers for database IDs. The REST API OpenAPI spec explicitly declares many resource IDs asintegerwithformat: int64(e.g. repositories, GPG keys, SSH keys), and the GraphQL API has migrated somedatabaseIdfields fromInttoBigInt.Changes
Updated all struct fields representing GitHub database IDs from
inttoint64, along with their downstream usage:Repository.ID,CreateCodespaceParams.RepositoryID,startCreateRequest.RepositoryID, plus interface/mock/test cascadingRulesetGraphQL.DatabaseId,RulesetREST.Id,BypassActors.ActorId,RulesetRule.RulesetId, and the skillsrulesetsResponse.IDdeployKey.ID,gpgKey.ID,sshKey.IDCache.IdAutolink.IDJobActor.ID,JobPullRequest.IDAll
strconv.Itoa()calls on these fields were updated tostrconv.FormatInt(x, 10).GraphQL response structs were also audited - only
RulesetGraphQL.DatabaseIdneeded updating. Others were already correct (GitHubUser.DatabaseIDisint64,FullDatabaseIDisstringfor GraphQLBigInt).Lint check
Added a custom
go/analysislinter (cmd/idtype-checker) that flags struct fields with ID-like names or JSON tags that useintinstead ofint64. Integrated intomake lintto prevent regressions.Validation
go build ./...passesmake lintreports 0 issues