Use int64 for GitHub database IDs#13403
Open
williammartin wants to merge 5 commits into
Open
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>
The idtype linter directly imports golang.org/x/tools/go/analysis, so go mod tidy correctly moves it from indirect to direct. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4a447a9 to
d120828
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes GitHub database ID handling by migrating relevant struct fields from Go’s platform-dependent int to int64, and adds a custom go/analysis linter to prevent regressions.
Changes:
- Updated multiple REST/GraphQL response/request structs to use
int64for GitHub database IDs (and adjusted downstream usages). - Replaced
strconv.Itoawithstrconv.FormatInt(..., 10)where IDs are stringified. - Added an
idtypeanalyzer +idtype-checkercommand, and wired it intomake lint.
Show a summary per file
| File | Description |
|---|---|
| pkg/linter/idtype/testdata/src/example/example.go | Analyzer test fixture covering flagged and non-flagged ID patterns. |
| pkg/linter/idtype/analyzer.go | New go/analysis analyzer that reports int-typed ID-like struct fields. |
| pkg/linter/idtype/analyzer_test.go | Runs the analyzer against analysistest testdata. |
| cmd/idtype-checker/main.go | singlechecker entrypoint for running the analyzer in lint. |
| Makefile | Adds idtype-checker execution to the lint target. |
| go.mod | Promotes golang.org/x/tools to a direct dependency for the analyzer tooling. |
| pkg/cmd/ssh-key/shared/user_keys.go | Switches SSH key ID field to int64. |
| pkg/cmd/ssh-key/list/list.go | Uses FormatInt for SSH key ID display. |
| pkg/cmd/skills/publish/publish.go | Switches rulesets API response ID field to int64. |
| pkg/cmd/ruleset/shared/shared.go | Switches ruleset-related ID fields (GraphQL/REST) to int64. |
| pkg/cmd/ruleset/list/list.go | Uses FormatInt for ruleset ID display. |
| pkg/cmd/ruleset/view/view.go | Uses FormatInt for ruleset IDs (both selected and displayed). |
| pkg/cmd/repo/deploy-key/list/http.go | Switches deploy key ID field to int64. |
| pkg/cmd/repo/deploy-key/list/list.go | Uses FormatInt for deploy key ID display. |
| pkg/cmd/repo/autolink/shared/autolink.go | Switches autolink ID field to int64. |
| pkg/cmd/gpg-key/delete/http.go | Switches GPG key ID field to int64. |
| pkg/cmd/gpg-key/delete/delete.go | Uses FormatInt for selected GPG key ID. |
| pkg/cmd/cache/shared/shared.go | Switches cache ID field to int64. |
| pkg/cmd/cache/delete/delete.go | Uses FormatInt when collecting cache IDs to delete. |
| pkg/cmd/agent-task/capi/job.go | Switches agent-task actor/PR ID fields to int64. |
| internal/codespaces/api/api.go | Switches codespaces repository/request IDs and related method params to int64. |
| pkg/cmd/codespace/common.go | Updates codespaces API client interface method signatures to use int64 repo IDs. |
| pkg/cmd/codespace/create.go | Updates helper signature to accept int64 repo IDs. |
| pkg/cmd/codespace/create_test.go | Updates mock signatures to match int64 repo ID APIs. |
| pkg/cmd/codespace/mock_api.go | Updates generated mock types/signatures and call capture fields to int64. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Files not reviewed (1)
- pkg/cmd/codespace/mock_api.go: Language not supported
- Files reviewed: 24/25 changed files
- Comments generated: 1
Replace manual string manipulation with strconv.Unquote and reflect.StructTag.Lookup to correctly parse both raw (backtick) and interpreted (double-quoted) struct tag literals. The previous implementation silently missed ID fields when tags used interpreted string literals with escape sequences. Add test cases with interpreted string literal tags using non-ID field names to isolate coverage of the JSON tag parsing path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The idtype linter has been moved to the 9247-idtype-linter branch for separate review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These functions still used int/strconv.Atoi, which would silently truncate cache IDs larger than 2^31-1 on 32-bit systems. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SamMorrowDrums
approved these changes
May 18, 2026
SamMorrowDrums
left a comment
Contributor
There was a problem hiding this comment.
Approving skills part, and 100% agree generally
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.Id, plusparseCacheIDanddeleteCacheByID(which still usedint/strconv.Atoi)Autolink.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).Future: Custom linter to prevent regressions
A custom
go/analysislinter that flags struct fields with ID-like names or JSON tags still usinginthas been prototyped on a separate branch:9247-idtype-linter. It's split out to keep this PR focused on the type changes. The linter correctly identifies all the violations fixed here.Linter output BEFORE this PR (27 violations)
Linter output AFTER this PR (0 violations)
Reviewer Notes
We should run A/C tests on this before merging.